Make --json and --quiet suppress automatic init messages
And any other messages that might be output before a command starts. Fixes a reversion introduced in version 5.20150727. During the optparse-applicative conversion, I needed a place to run per-command global option setters, and I made it get run during the seek stage. But that is too late to have --json and --quiet disable output produced in the check stage. Fix is just to run those per-command global option setters at the same time as the all-command global option setters. This commit was sponsored by Thom May.
This commit is contained in:
parent
c9082cf0e4
commit
219e2fa157
6 changed files with 21 additions and 14 deletions
15
Command.hs
15
Command.hs
|
@ -33,7 +33,7 @@ import Types.ActionItem
|
|||
command :: String -> CommandSection -> String -> CmdParamsDesc -> (CmdParamsDesc -> CommandParser) -> Command
|
||||
command name section desc paramdesc mkparser =
|
||||
Command commonChecks False False name paramdesc
|
||||
section desc (mkparser paramdesc) Nothing
|
||||
section desc (mkparser paramdesc) [] Nothing
|
||||
|
||||
{- Simple option parser that takes all non-option params as-is. -}
|
||||
withParams :: (CmdParams -> v) -> CmdParamsDesc -> Parser v
|
||||
|
@ -68,18 +68,9 @@ noMessages c = c { cmdnomessages = True }
|
|||
noRepo :: (String -> Parser (IO ())) -> Command -> Command
|
||||
noRepo a c = c { cmdnorepo = Just (a (cmdparamdesc c)) }
|
||||
|
||||
{- Adds global options to a command's option parser, and modifies its seek
|
||||
- option to first run actions for them.
|
||||
-}
|
||||
{- Adds global options to a command's. -}
|
||||
withGlobalOptions :: [GlobalOption] -> Command -> Command
|
||||
withGlobalOptions os c = c { cmdparser = apply <$> mixin (cmdparser c) }
|
||||
where
|
||||
mixin p = (,)
|
||||
<$> p
|
||||
<*> combineGlobalOptions os
|
||||
apply (seek, globalsetters) = do
|
||||
void $ getParsed globalsetters
|
||||
seek
|
||||
withGlobalOptions os c = c { cmdglobaloptions = cmdglobaloptions c ++ os }
|
||||
|
||||
{- For start and perform stages to indicate what step to run next. -}
|
||||
next :: a -> Annex (Maybe a)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue