aboutsummaryrefslogtreecommitdiff
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-10 02:18:08 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-10 02:18:08 -0400
commitbc9b0307cf427ab8ca6532c2ae4e0086e7ad4a4a (patch)
tree43d0984a200cb6ca68335da30b2574650955e2a4 /CmdLine.hs
parentccd76ebf641ad481e549da97c85f73101a3149fd (diff)
improve global options display in --help
Put them in the help of subcommands, not the main command. And, hide them from the synopsis, to avoid cluttering it.
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index e19b54de7..de1b3e7da 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -31,6 +31,7 @@ import Annex.Content
import Annex.Environment
import Command
import Types.Messages
+import CmdLine.GlobalSetter
{- Runs the passed command line. -}
dispatch :: Bool -> CmdParams -> [Command] -> [Parser GlobalSetter] -> [(String, String)] -> IO Git.Repo -> String -> String -> IO ()
@@ -43,7 +44,7 @@ dispatch fuzzyok allargs allcmds globaloptions fields getgitrepo progname progde
Annex.eval state $ do
checkEnvironment
forM_ fields $ uncurry Annex.setField
- ((cmd, seek), globalconfig) <- parsewith cmdparser
+ (cmd, seek, globalconfig) <- parsewith cmdparser
(\a -> inRepo $ a . Just)
when (cmdnomessages cmd) $
Annex.setOutput QuietOutput
@@ -54,7 +55,7 @@ dispatch fuzzyok allargs allcmds globaloptions fields getgitrepo progname progde
performCommandAction cmd seek $
shutdown $ cmdnocommit cmd
go (Left norepo) = do
- ((_, a), _) <- parsewith
+ (_, a, _globalconfig) <- parsewith
(fromMaybe (throw norepo) . cmdnorepo)
(\a -> a =<< Git.Config.global)
a
@@ -81,20 +82,19 @@ dispatch fuzzyok allargs allcmds globaloptions fields getgitrepo progname progde
Just n -> n:args
{- Parses command line, selecting one of the commands from the list. -}
-parseCmd :: String -> String -> [Parser GlobalSetter] -> CmdParams -> [Command] -> (Command -> O.Parser v) -> O.ParserResult ((Command, v), GlobalSetter)
+parseCmd :: String -> String -> [Parser GlobalSetter] -> CmdParams -> [Command] -> (Command -> O.Parser v) -> O.ParserResult (Command, v, GlobalSetter)
parseCmd progname progdesc globaloptions allargs allcmds getparser =
O.execParserPure (O.prefs O.idm) pinfo allargs
where
- pinfo = O.info
- (O.helper <*> ((,) <$> subcmds <*> combineGlobalSetters globaloptions))
- (O.progDescDoc (Just intro))
+ pinfo = O.info (O.helper <*> subcmds) (O.progDescDoc (Just intro))
subcmds = O.hsubparser $ mconcat $ map mkcommand allcmds
mkcommand c = O.command (cmdname c) $ O.info (mkparser c) $ O.fullDesc
<> O.header (synopsis (progname ++ " " ++ cmdname c) (cmddesc c))
<> O.footer ("For details, run: " ++ progname ++ " help " ++ cmdname c)
- mkparser c = (,)
+ mkparser c = (,,)
<$> pure c
<*> getparser c
+ <*> combineGlobalSetters globaloptions
synopsis n d = n ++ " - " ++ d
intro = mconcat $ concatMap (\l -> [H.text l, H.line])
(synopsis progname progdesc : commandList allcmds)