summaryrefslogtreecommitdiff
path: root/Command.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-02-16 13:24:16 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-02-16 13:24:35 -0400
commit34bcff4cba4a8f866110309ae00bcd4a8deb7551 (patch)
treea187a962bb859d8a77ef59c459e5cc2ace0dd795 /Command.hs
parentb65b8fe7f1b63403e8b1fd1e149e0adb5b00277d (diff)
make query commands not output extraneous messages
config group groupwanted numcopies schedule wanted required: Avoid displaying extraneous messages about repository auto-init, git-annex branch merging, etc, when being used to get information.
Diffstat (limited to 'Command.hs')
-rw-r--r--Command.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Command.hs b/Command.hs
index f8d4fe32b..58f57762e 100644
--- a/Command.hs
+++ b/Command.hs
@@ -22,12 +22,14 @@ import CmdLine.GlobalSetter as ReExported
import CmdLine.GitAnnex.Options as ReExported
import CmdLine.Batch as ReExported
import Options.Applicative as ReExported hiding (command)
+import qualified Annex
import qualified Git
import Annex.Init
import Config
import Utility.Daemon
import Types.Transfer
import Types.ActionItem
+import Types.Messages
{- Generates a normal Command -}
command :: String -> CommandSection -> String -> CmdParamsDesc -> (CmdParamsDesc -> CommandParser) -> Command
@@ -63,6 +65,16 @@ noCommit c = c { cmdnocommit = True }
noMessages :: Command -> Command
noMessages c = c { cmdnomessages = True }
+{- Undoes noMessages -}
+allowMessages :: Annex ()
+allowMessages = do
+ curr <- Annex.getState Annex.output
+ case outputType curr of
+ QuietOutput -> Annex.setOutput NormalOutput
+ _ -> noop
+ Annex.changeState $ \s -> s
+ { Annex.output = (Annex.output s) { implicitMessages = True } }
+
{- Adds a fallback action to a command, that will be run if it's used
- outside a git repository. -}
noRepo :: (String -> Parser (IO ())) -> Command -> Command