From d010ee969c82d6bb2d0f60c4b1ce2de3543e0920 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 27 Mar 2013 13:51:24 -0400 Subject: Per-command usage messages. --- CmdLine.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'CmdLine.hs') 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). -- cgit v1.2.3