display cmdparamdesc in optparse-applicative usage messages
Since optparse-applicative display "FOO" as "[FOO]", the paramOptional modifier which wrapped it in square brackets was removed from most places.
This commit is contained in:
parent
a2ba701056
commit
3125da54f6
7 changed files with 15 additions and 11 deletions
|
@ -58,7 +58,7 @@ commandUsage cmd = unlines
|
||||||
|
|
||||||
{- Descriptions of params used in usage messages. -}
|
{- Descriptions of params used in usage messages. -}
|
||||||
paramPaths :: String
|
paramPaths :: String
|
||||||
paramPaths = paramOptional $ paramRepeating paramPath -- most often used
|
paramPaths = paramRepeating paramPath -- most often used
|
||||||
paramPath :: String
|
paramPath :: String
|
||||||
paramPath = "PATH"
|
paramPath = "PATH"
|
||||||
paramKey :: String
|
paramKey :: String
|
||||||
|
@ -114,6 +114,6 @@ paramNothing = ""
|
||||||
paramRepeating :: String -> String
|
paramRepeating :: String -> String
|
||||||
paramRepeating s = s ++ " ..."
|
paramRepeating s = s ++ " ..."
|
||||||
paramOptional :: String -> String
|
paramOptional :: String -> String
|
||||||
paramOptional s = "[" ++ s ++ "]"
|
paramOptional s = s
|
||||||
paramPair :: String -> String -> String
|
paramPair :: String -> String -> String
|
||||||
paramPair a b = a ++ " " ++ b
|
paramPair a b = a ++ " " ++ b
|
||||||
|
|
12
Command.hs
12
Command.hs
|
@ -36,13 +36,17 @@ import CmdLine.GitAnnex.Options as ReExported
|
||||||
import qualified Options.Applicative as O
|
import qualified Options.Applicative as O
|
||||||
|
|
||||||
{- Generates a normal Command -}
|
{- Generates a normal Command -}
|
||||||
command :: String -> String -> CommandSection -> String -> CommandParser -> Command
|
command :: String -> String -> CommandSection -> String -> (Command -> CommandParser) -> Command
|
||||||
command = Command [] Nothing commonChecks False False
|
command name paramdesc section desc parser = c
|
||||||
|
where
|
||||||
|
c = Command [] Nothing commonChecks False False name paramdesc section desc (parser c)
|
||||||
|
|
||||||
{- Simple CommandParser generator, for when the CommandSeek wants all
|
{- Simple CommandParser generator, for when the CommandSeek wants all
|
||||||
- non-option parameters. -}
|
- non-option parameters. -}
|
||||||
commandParser :: (CmdParams -> CommandSeek) -> CommandParser
|
commandParser :: (CmdParams -> CommandSeek) -> Command -> CommandParser
|
||||||
commandParser mkseek = mkseek <$> O.many (O.argument O.str O.idm)
|
commandParser mkseek c = mkseek <$> O.many cmdparams
|
||||||
|
where
|
||||||
|
cmdparams = O.argument O.str (O.metavar (cmdparamdesc c))
|
||||||
|
|
||||||
{- Indicates that a command doesn't need to commit any changes to
|
{- Indicates that a command doesn't need to commit any changes to
|
||||||
- the git-annex branch. -}
|
- the git-annex branch. -}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import System.Console.GetOpt
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
cmd = noCommit $ noRepo startNoRepo $ dontCheck repoExists $
|
||||||
command "help" (paramOptional "COMMAND") seek SectionCommon "display help"
|
command "help" "COMMAND" seek SectionCommon "display help"
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
seek = withWords start
|
seek = withWords start
|
||||||
|
|
|
@ -80,7 +80,7 @@ type StatState = StateT StatInfo Annex
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = noCommit $ dontCheck repoExists $ withOptions (jsonOption : bytesOption : annexedMatchingOptions) $
|
cmd = noCommit $ dontCheck repoExists $ withOptions (jsonOption : bytesOption : annexedMatchingOptions) $
|
||||||
command "info" (paramOptional $ paramRepeating paramItem) seek SectionQuery
|
command "info" (paramRepeating paramItem) seek SectionQuery
|
||||||
"shows information about the specified item or the repository as a whole"
|
"shows information about the specified item or the repository as a whole"
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
|
|
|
@ -20,7 +20,7 @@ import qualified Remote
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = notDirect $ command "rekey"
|
cmd = notDirect $ command "rekey"
|
||||||
(paramOptional $ paramRepeating $ paramPair paramPath paramKey)
|
(paramRepeating $ paramPair paramPath paramKey)
|
||||||
seek SectionPlumbing "change keys used for files"
|
seek SectionPlumbing "change keys used for files"
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
|
|
|
@ -53,7 +53,7 @@ import qualified Data.Map as M
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = withOptions syncOptions $
|
cmd = withOptions syncOptions $
|
||||||
command "sync" (paramOptional (paramRepeating paramRemote))
|
command "sync" (paramRepeating paramRemote)
|
||||||
seek SectionCommon "synchronize local repository with remotes"
|
seek SectionCommon "synchronize local repository with remotes"
|
||||||
|
|
||||||
syncOptions :: [Option]
|
syncOptions :: [Option]
|
||||||
|
|
|
@ -18,7 +18,7 @@ import Command.View (checkoutViewBranch)
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = notBareRepo $ notDirect $
|
cmd = notBareRepo $ notDirect $
|
||||||
command "vpop" (paramOptional paramNumber) seek SectionMetaData
|
command "vpop" paramNumber seek SectionMetaData
|
||||||
"switch back to previous view"
|
"switch back to previous view"
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
|
|
Loading…
Reference in a new issue