Command data structure tweaking
This commit is contained in:
parent
cdcf0aac71
commit
47be4383b7
3 changed files with 10 additions and 8 deletions
|
@ -67,8 +67,8 @@ usage header cmds options = usageInfo top options ++ commands
|
||||||
showcmd c =
|
showcmd c =
|
||||||
cmdname c ++
|
cmdname c ++
|
||||||
pad (longest cmdname + 1) (cmdname c) ++
|
pad (longest cmdname + 1) (cmdname c) ++
|
||||||
cmdparams c ++
|
cmdparamdesc c ++
|
||||||
pad (longest cmdparams + 2) (cmdparams c) ++
|
pad (longest cmdparamdesc + 2) (cmdparamdesc c) ++
|
||||||
cmddesc c
|
cmddesc c
|
||||||
pad n s = replicate (n - length s) ' '
|
pad n s = replicate (n - length s) ' '
|
||||||
longest f = foldl max 0 $ map (length . f) cmds
|
longest f = foldl max 0 $ map (length . f) cmds
|
||||||
|
|
|
@ -33,12 +33,12 @@ type CommandCleanup = Annex Bool
|
||||||
|
|
||||||
{- A command is defined by specifying these things. -}
|
{- A command is defined by specifying these things. -}
|
||||||
data Command = Command {
|
data Command = Command {
|
||||||
cmdnorepo :: Maybe (IO ()),
|
cmdnorepo :: Maybe (IO ()), -- an action to run when not in a repo
|
||||||
cmdcheck :: [CommandCheck],
|
cmdcheck :: [CommandCheck], -- check stage
|
||||||
cmdname :: String,
|
cmdname :: String,
|
||||||
cmdparams :: String,
|
cmdparamdesc :: String, -- description of params for usage
|
||||||
cmdseek :: [CommandSeek],
|
cmdseek :: [CommandSeek], -- seek stage
|
||||||
cmddesc :: String
|
cmddesc :: String -- description of command for usage
|
||||||
}
|
}
|
||||||
|
|
||||||
{- CommandCheck functions can be compared using their unique id. -}
|
{- CommandCheck functions can be compared using their unique id. -}
|
||||||
|
|
|
@ -36,7 +36,9 @@ cmds_notreadonly = concat
|
||||||
cmds :: [Command]
|
cmds :: [Command]
|
||||||
cmds = map adddirparam $ cmds_readonly ++ cmds_notreadonly
|
cmds = map adddirparam $ cmds_readonly ++ cmds_notreadonly
|
||||||
where
|
where
|
||||||
adddirparam c = c { cmdparams = "DIRECTORY " ++ cmdparams c }
|
adddirparam c = c
|
||||||
|
{ cmdparamdesc = "DIRECTORY " ++ cmdparamdesc c
|
||||||
|
}
|
||||||
|
|
||||||
options :: [OptDescr (Annex ())]
|
options :: [OptDescr (Annex ())]
|
||||||
options = commonOptions ++
|
options = commonOptions ++
|
||||||
|
|
Loading…
Reference in a new issue