get rid of implicitMessages state
Oh joyous day, this is probably git-annex's oldest implementation wart, source of much unncessary bother. Now that we have a StartMessage, showEndResult' can look at it to know if it needs to display an end message or not. This is also going to be faster, because it avoids an uncessary state lookup for each file processed.
This commit is contained in:
parent
8e5ea28c26
commit
70bc30acb1
4 changed files with 36 additions and 35 deletions
18
Messages.hs
18
Messages.hs
|
@ -9,6 +9,7 @@ module Messages (
|
|||
showStart,
|
||||
showStart',
|
||||
showStartMessage,
|
||||
showEndMessage,
|
||||
StartMessage(..),
|
||||
ActionItem(..),
|
||||
mkActionItem,
|
||||
|
@ -43,7 +44,6 @@ module Messages (
|
|||
debugEnabled,
|
||||
commandProgressDisabled,
|
||||
outputMessage,
|
||||
implicitMessage,
|
||||
withMessageState,
|
||||
prompt,
|
||||
) where
|
||||
|
@ -97,13 +97,15 @@ showStartMessage (StartUsualMessages command ai) = do
|
|||
outputType <$> Annex.getState Annex.output >>= \case
|
||||
QuietOutput -> Annex.setOutput NormalOutput
|
||||
_ -> noop
|
||||
Annex.changeState $ \s -> s
|
||||
{ Annex.output = (Annex.output s) { implicitMessages = True } }
|
||||
showStartMessage (StartMessage command ai)
|
||||
showStartMessage (CustomOutput _) = do
|
||||
Annex.setOutput QuietOutput
|
||||
Annex.changeState $ \s -> s
|
||||
{ Annex.output = (Annex.output s) { implicitMessages = False } }
|
||||
|
||||
-- Only show end result if the StartMessage is one that gets displayed.
|
||||
showEndMessage :: StartMessage -> Bool -> Annex ()
|
||||
showEndMessage (StartMessage _ _) = showEndResult
|
||||
showEndMessage (StartUsualMessages _ _) = showEndResult
|
||||
showEndMessage (CustomOutput _) = const noop
|
||||
|
||||
showNote :: String -> Annex ()
|
||||
showNote s = outputMessage (JSON.note s) $ "(" ++ s ++ ") "
|
||||
|
@ -275,12 +277,6 @@ commandProgressDisabled = withMessageState $ \s -> return $
|
|||
JSONOutput _ -> True
|
||||
NormalOutput -> concurrentOutputEnabled s
|
||||
|
||||
{- Use to show a message that is displayed implicitly, and so might be
|
||||
- disabled when running a certian command that needs more control over its
|
||||
- output. -}
|
||||
implicitMessage :: Annex () -> Annex ()
|
||||
implicitMessage = whenM (implicitMessages <$> Annex.getState Annex.output)
|
||||
|
||||
{- Prevents any concurrent console access while running an action, so
|
||||
- that the action is the only thing using the console, and can eg prompt
|
||||
- the user.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue