add startingNoMessage
Fixes the last wart in the StartMessage transition. A few commands include other CommandStart actions that generate output, and do not themselves need to display a start/end message.
This commit is contained in:
parent
70bc30acb1
commit
ba2551da6f
6 changed files with 17 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command infrastructure
|
||||
-
|
||||
- Copyright 2010-2016 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2019 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -82,6 +82,11 @@ starting msg t a = next (StartMessage msg (mkActionItem t), a)
|
|||
startingUsualMessages :: MkActionItem t => String -> t -> CommandPerform -> CommandStart
|
||||
startingUsualMessages msg t a = next (StartUsualMessages msg (mkActionItem t), a)
|
||||
|
||||
{- When no message should be displayed at start/end, but messages can still
|
||||
- be displayed when using eg includeCommandAction. -}
|
||||
startingNoMessage :: MkActionItem t => t -> CommandPerform -> CommandStart
|
||||
startingNoMessage t a = next (StartNoMessage (mkActionItem t), a)
|
||||
|
||||
{- For commands that do not display usual start or end messages,
|
||||
- but have some other custom output. -}
|
||||
startingCustomOutput :: MkActionItem t => t -> CommandPerform -> CommandStart
|
||||
|
|
|
@ -40,7 +40,7 @@ seek :: CmdParams -> CommandSeek
|
|||
seek = withNothing (commandAction start)
|
||||
|
||||
start :: CommandStart
|
||||
start = starting "map" (ActionItemOther Nothing) $ do
|
||||
start = startingNoMessage (ActionItemOther Nothing) $ do
|
||||
rs <- combineSame <$> (spider =<< gitRepo)
|
||||
|
||||
umap <- uuidDescMap
|
||||
|
|
|
@ -247,7 +247,7 @@ toHereStart removewhen afile key ai = case removewhen of
|
|||
RemoveNever -> stopUnless (not <$> inAnnex key) go
|
||||
RemoveSafe -> go
|
||||
where
|
||||
go = startingCustomOutput (OnlyActionOn key ai) $ do
|
||||
go = startingNoMessage (OnlyActionOn key ai) $ do
|
||||
rs <- Remote.keyPossibilities key
|
||||
forM_ rs $ \r ->
|
||||
includeCommandAction $
|
||||
|
|
|
@ -630,7 +630,7 @@ seekSyncContent o rs currbranch = do
|
|||
-- Run syncFile as a command action so file transfers run
|
||||
-- concurrently.
|
||||
let ai = OnlyActionOn k (ActionItemKey k)
|
||||
commandAction $ startingCustomOutput ai $ do
|
||||
commandAction $ startingNoMessage ai $ do
|
||||
whenM (syncFile ebloom rs af k) $
|
||||
void $ liftIO $ tryPutMVar mvar ()
|
||||
next $ return True
|
||||
|
|
|
@ -98,13 +98,14 @@ showStartMessage (StartUsualMessages command ai) = do
|
|||
QuietOutput -> Annex.setOutput NormalOutput
|
||||
_ -> noop
|
||||
showStartMessage (StartMessage command ai)
|
||||
showStartMessage (CustomOutput _) = do
|
||||
Annex.setOutput QuietOutput
|
||||
showStartMessage (StartNoMessage _) = noop
|
||||
showStartMessage (CustomOutput _) = Annex.setOutput QuietOutput
|
||||
|
||||
-- Only show end result if the StartMessage is one that gets displayed.
|
||||
showEndMessage :: StartMessage -> Bool -> Annex ()
|
||||
showEndMessage (StartMessage _ _) = showEndResult
|
||||
showEndMessage (StartUsualMessages _ _) = showEndResult
|
||||
showEndMessage (StartNoMessage _) = const noop
|
||||
showEndMessage (CustomOutput _) = const noop
|
||||
|
||||
showNote :: String -> Annex ()
|
||||
|
|
|
@ -47,14 +47,18 @@ data StartMessage
|
|||
| StartUsualMessages String ActionItem
|
||||
-- ^ Like StartMessage, but makes sure to enable usual message
|
||||
-- display in case it was disabled by cmdnomessages.
|
||||
| StartNoMessage ActionItem
|
||||
-- ^ Starts, without displaying any message but also without
|
||||
-- disabling display of any of the usual messages.
|
||||
| CustomOutput ActionItem
|
||||
-- ^ Prevents any start, end, or other implicit messages from
|
||||
-- ^ Prevents any start, end, or other usual messages from
|
||||
-- being displayed, letting a command output its own custom format.
|
||||
deriving (Show)
|
||||
|
||||
instance MkActionItem StartMessage where
|
||||
mkActionItem (StartMessage _ ai) = ai
|
||||
mkActionItem (StartUsualMessages _ ai) = ai
|
||||
mkActionItem (StartNoMessage ai) = ai
|
||||
mkActionItem (CustomOutput ai) = ai
|
||||
|
||||
{- A command is defined by specifying these things. -}
|
||||
|
|
Loading…
Reference in a new issue