summaryrefslogtreecommitdiff
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-27 13:51:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-27 13:51:24 -0400
commitd010ee969c82d6bb2d0f60c4b1ce2de3543e0920 (patch)
treefef62e7155b8ae9977ce51294339693f548cd964 /CmdLine.hs
parent3b1d7915569b0dbfa6cefc54e0537d19290e08bf (diff)
Per-command usage messages.
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index 489935453..db46cba82 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -48,7 +48,7 @@ dispatch fuzzyok allargs allcmds commonoptions fields header getgitrepo = do
err msg = msg ++ "\n\n" ++ usage header allcmds
cmd = Prelude.head cmds
(fuzzy, cmds, name, args) = findCmd fuzzyok allargs allcmds err
- (flags, params) = getOptCmd args cmd commonoptions err
+ (flags, params) = getOptCmd args cmd commonoptions
checkfuzzy = when fuzzy $
inRepo $ Git.AutoCorrect.prepare name cmdname cmds
@@ -74,12 +74,15 @@ findCmd fuzzyok argv cmds err
{- Parses command line options, and returns actions to run to configure flags
- and the remaining parameters for the command. -}
-getOptCmd :: Params -> Command -> [Option] -> (String -> String) -> (Flags, Params)
-getOptCmd argv cmd commonoptions err = check $
+getOptCmd :: Params -> Command -> [Option] -> (Flags, Params)
+getOptCmd argv cmd commonoptions = check $
getOpt Permute (commonoptions ++ cmdoptions cmd) argv
where
check (flags, rest, []) = (flags, rest)
- check (_, _, errs) = error $ err $ concat errs
+ check (_, _, errs) = error $ unlines
+ [ concat errs
+ , commandUsage cmd
+ ]
{- Runs a list of Annex actions. Catches IO errors and continues
- (but explicitly thrown errors terminate the whole command).