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:
Joey Hess 2019-06-12 14:11:23 -04:00
parent 70bc30acb1
commit ba2551da6f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 17 additions and 7 deletions

View file

@ -1,6 +1,6 @@
{- git-annex command infrastructure {- 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. - 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 :: MkActionItem t => String -> t -> CommandPerform -> CommandStart
startingUsualMessages msg t a = next (StartUsualMessages msg (mkActionItem t), a) 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, {- For commands that do not display usual start or end messages,
- but have some other custom output. -} - but have some other custom output. -}
startingCustomOutput :: MkActionItem t => t -> CommandPerform -> CommandStart startingCustomOutput :: MkActionItem t => t -> CommandPerform -> CommandStart

View file

@ -40,7 +40,7 @@ seek :: CmdParams -> CommandSeek
seek = withNothing (commandAction start) seek = withNothing (commandAction start)
start :: CommandStart start :: CommandStart
start = starting "map" (ActionItemOther Nothing) $ do start = startingNoMessage (ActionItemOther Nothing) $ do
rs <- combineSame <$> (spider =<< gitRepo) rs <- combineSame <$> (spider =<< gitRepo)
umap <- uuidDescMap umap <- uuidDescMap

View file

@ -247,7 +247,7 @@ toHereStart removewhen afile key ai = case removewhen of
RemoveNever -> stopUnless (not <$> inAnnex key) go RemoveNever -> stopUnless (not <$> inAnnex key) go
RemoveSafe -> go RemoveSafe -> go
where where
go = startingCustomOutput (OnlyActionOn key ai) $ do go = startingNoMessage (OnlyActionOn key ai) $ do
rs <- Remote.keyPossibilities key rs <- Remote.keyPossibilities key
forM_ rs $ \r -> forM_ rs $ \r ->
includeCommandAction $ includeCommandAction $

View file

@ -630,7 +630,7 @@ seekSyncContent o rs currbranch = do
-- Run syncFile as a command action so file transfers run -- Run syncFile as a command action so file transfers run
-- concurrently. -- concurrently.
let ai = OnlyActionOn k (ActionItemKey k) let ai = OnlyActionOn k (ActionItemKey k)
commandAction $ startingCustomOutput ai $ do commandAction $ startingNoMessage ai $ do
whenM (syncFile ebloom rs af k) $ whenM (syncFile ebloom rs af k) $
void $ liftIO $ tryPutMVar mvar () void $ liftIO $ tryPutMVar mvar ()
next $ return True next $ return True

View file

@ -98,13 +98,14 @@ showStartMessage (StartUsualMessages command ai) = do
QuietOutput -> Annex.setOutput NormalOutput QuietOutput -> Annex.setOutput NormalOutput
_ -> noop _ -> noop
showStartMessage (StartMessage command ai) showStartMessage (StartMessage command ai)
showStartMessage (CustomOutput _) = do showStartMessage (StartNoMessage _) = noop
Annex.setOutput QuietOutput showStartMessage (CustomOutput _) = Annex.setOutput QuietOutput
-- Only show end result if the StartMessage is one that gets displayed. -- Only show end result if the StartMessage is one that gets displayed.
showEndMessage :: StartMessage -> Bool -> Annex () showEndMessage :: StartMessage -> Bool -> Annex ()
showEndMessage (StartMessage _ _) = showEndResult showEndMessage (StartMessage _ _) = showEndResult
showEndMessage (StartUsualMessages _ _) = showEndResult showEndMessage (StartUsualMessages _ _) = showEndResult
showEndMessage (StartNoMessage _) = const noop
showEndMessage (CustomOutput _) = const noop showEndMessage (CustomOutput _) = const noop
showNote :: String -> Annex () showNote :: String -> Annex ()

View file

@ -47,14 +47,18 @@ data StartMessage
| StartUsualMessages String ActionItem | StartUsualMessages String ActionItem
-- ^ Like StartMessage, but makes sure to enable usual message -- ^ Like StartMessage, but makes sure to enable usual message
-- display in case it was disabled by cmdnomessages. -- 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 | 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. -- being displayed, letting a command output its own custom format.
deriving (Show) deriving (Show)
instance MkActionItem StartMessage where instance MkActionItem StartMessage where
mkActionItem (StartMessage _ ai) = ai mkActionItem (StartMessage _ ai) = ai
mkActionItem (StartUsualMessages _ ai) = ai mkActionItem (StartUsualMessages _ ai) = ai
mkActionItem (StartNoMessage ai) = ai
mkActionItem (CustomOutput ai) = ai mkActionItem (CustomOutput ai) = ai
{- A command is defined by specifying these things. -} {- A command is defined by specifying these things. -}