support cmdnorepo actions, also using getopt-applicative there

This commit is contained in:
Joey Hess 2015-07-08 15:39:05 -04:00
parent 6e5c1f8db3
commit 92d8f80bff
10 changed files with 54 additions and 68 deletions

View file

@ -20,10 +20,11 @@ import Assistant.Install
import System.Environment
cmd :: Command
cmd = noRepo checkNoRepoOpts $ dontCheck repoExists $ withOptions options $
notBareRepo $ command "assistant" SectionCommon
"automatically sync changes"
paramNothing (withParams seek)
cmd = dontCheck repoExists $ withOptions options $ notBareRepo $
noRepo (withParams checkNoRepoOpts) $
command "assistant" SectionCommon
"automatically sync changes"
paramNothing (withParams seek)
options :: [Option]
options =

View file

@ -22,9 +22,12 @@ import qualified Command.Fsck
import System.Console.GetOpt
cmd :: Command
cmd = noCommit $ noRepo startNoRepo $ dontCheck repoExists $
command "help" SectionCommon "display help"
"COMMAND" (withParams seek)
cmd = noCommit $ dontCheck repoExists $
noRepo (parseparams startNoRepo) $
command "help" SectionCommon "display help"
"COMMAND" (parseparams seek)
where
parseparams = withParams
seek :: CmdParams -> CommandSeek
seek = withWords start

View file

@ -12,10 +12,12 @@ import Command
import Messages
cmd :: Command
cmd = noRepo startIO $ dontCheck repoExists $
cmd = noRepo (parseparams startIO) $ dontCheck repoExists $
command "test" SectionTesting
"run built-in test suite"
paramNothing (withParams seek)
paramNothing (parseparams seek)
where
parseparams = withParams
seek :: CmdParams -> CommandSeek
seek = withWords start

View file

@ -18,10 +18,12 @@ import qualified Remote
import qualified Backend
cmd :: Command
cmd = withOptions [rawOption] $
noCommit $ noRepo startNoRepo $ dontCheck repoExists $
command "version" SectionQuery "show version info"
paramNothing (withParams seek)
cmd = withOptions [rawOption] $ dontCheck repoExists $ noCommit $
noRepo (parseparams startNoRepo) $
command "version" SectionQuery "show version info"
paramNothing (parseparams seek)
where
parseparams = withParams
rawOption :: Option
rawOption = flagOption [] "raw" "output only program version"

View file

@ -39,9 +39,10 @@ import System.Environment (getArgs)
cmd :: Command
cmd = withOptions [listenOption] $
noCommit $ noRepo startNoRepo $ dontCheck repoExists $ notBareRepo $
command "webapp" SectionCommon "launch webapp"
paramNothing (withParams seek)
noCommit $ dontCheck repoExists $ notBareRepo $
noRepo (withParams startNoRepo) $
command "webapp" SectionCommon "launch webapp"
paramNothing (withParams seek)
listenOption :: Option
listenOption = fieldOption [] "listen" paramAddress

View file

@ -12,9 +12,12 @@ import Command
import Assistant.XMPP.Git
cmd :: Command
cmd = noCommit $ noRepo startNoRepo $ dontCheck repoExists $
command "xmppgit" SectionPlumbing "git to XMPP relay"
paramNothing (withParams seek)
cmd = noCommit $ dontCheck repoExists $
noRepo (parseparams startNoRepo) $
command "xmppgit" SectionPlumbing "git to XMPP relay"
paramNothing (parseparams seek)
where
parseparams = withParams
seek :: CmdParams -> CommandSeek
seek = withWords start