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.
This commit is contained in:
Joey Hess 2017-02-16 13:24:16 -04:00
parent baa2ab2c7d
commit d0651bb567
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
10 changed files with 51 additions and 15 deletions

View file

@ -11,7 +11,8 @@ import Command
import Logs.Config
cmd :: Command
cmd = command "config" SectionSetup "configuration stored in git-annex branch"
cmd = noMessages $ command "config" SectionSetup
"configuration stored in git-annex branch"
paramNothing (seek <$$> optParser)
data Action
@ -47,11 +48,13 @@ optParser _ = setconfig <|> getconfig <|> unsetconfig
seek :: Action -> CommandSeek
seek (SetConfig name val) = commandAction $ do
allowMessages
showStart name val
next $ next $ do
setGlobalConfig name val
return True
seek (UnsetConfig name) = commandAction $ do
allowMessages
showStart name "unset"
next $ next $ do
unsetGlobalConfig name

View file

@ -15,7 +15,7 @@ import Types.Group
import qualified Data.Set as S
cmd :: Command
cmd = command "group" SectionSetup "add a repository to a group"
cmd = noMessages $ command "group" SectionSetup "add a repository to a group"
(paramPair paramRemote paramDesc) (withParams seek)
seek :: CmdParams -> CommandSeek
@ -23,12 +23,13 @@ seek = withWords start
start :: [String] -> CommandStart
start (name:g:[]) = do
allowMessages
showStart "group" name
u <- Remote.nameToUUID name
next $ setGroup u g
start (name:[]) = do
u <- Remote.nameToUUID name
showRaw . unwords . S.toList =<< lookupGroups u
liftIO . putStrLn . unwords . S.toList =<< lookupGroups u
stop
start _ = giveup "Specify a repository and a group."

View file

@ -12,7 +12,7 @@ import Logs.PreferredContent
import Command.Wanted (performGet, performSet)
cmd :: Command
cmd = command "groupwanted" SectionSetup
cmd = noMessages $ command "groupwanted" SectionSetup
"get or set groupwanted expression"
(paramPair paramGroup (paramOptional paramExpression))
(withParams seek)
@ -23,6 +23,7 @@ seek = withWords start
start :: [String] -> CommandStart
start (g:[]) = next $ performGet groupPreferredContentMapRaw g
start (g:expr:[]) = do
allowMessages
showStart "groupwanted" g
next $ performSet groupPreferredContentSet expr g
start _ = giveup "Specify a group."

View file

@ -10,10 +10,9 @@ module Command.NumCopies where
import Command
import qualified Annex
import Annex.NumCopies
import Types.Messages
cmd :: Command
cmd = command "numcopies" SectionSetup
cmd = noMessages $ command "numcopies" SectionSetup
"configure desired number of copies"
paramNumber (withParams seek)
@ -35,7 +34,6 @@ start _ = giveup "Specify a single number."
startGet :: CommandStart
startGet = next $ next $ do
Annex.setOutput QuietOutput
v <- getGlobalNumCopies
case v of
Just n -> liftIO $ putStrLn $ show $ fromNumCopies n
@ -49,6 +47,7 @@ startGet = next $ next $ do
startSet :: Int -> CommandStart
startSet n = do
allowMessages
showStart "numcopies" (show n)
next $ next $ do
setGlobalNumCopies $ NumCopies n

View file

@ -8,16 +8,14 @@
module Command.Schedule where
import Command
import qualified Annex
import qualified Remote
import Logs.Schedule
import Types.ScheduledActivity
import Types.Messages
import qualified Data.Set as S
cmd :: Command
cmd = command "schedule" SectionSetup "get or set scheduled jobs"
cmd = noMessages $ command "schedule" SectionSetup "get or set scheduled jobs"
(paramPair paramRemote (paramOptional paramExpression))
(withParams seek)
@ -29,6 +27,7 @@ start = parse
where
parse (name:[]) = go name performGet
parse (name:expr:[]) = go name $ \uuid -> do
allowMessages
showStart "schedule" name
performSet expr uuid
parse _ = giveup "Specify a repository."
@ -39,7 +38,6 @@ start = parse
performGet :: UUID -> CommandPerform
performGet uuid = do
Annex.setOutput QuietOutput
s <- scheduleGet uuid
liftIO $ putStrLn $ intercalate "; " $
map fromScheduledActivity $ S.toList s

View file

@ -8,10 +8,8 @@
module Command.Wanted where
import Command
import qualified Annex
import qualified Remote
import Logs.PreferredContent
import Types.Messages
import Types.StandardGroups
import qualified Data.Map as M
@ -27,7 +25,8 @@ cmd'
-> Annex (M.Map UUID PreferredContentExpression)
-> (UUID -> PreferredContentExpression -> Annex ())
-> Command
cmd' name desc getter setter = command name SectionSetup desc pdesc (withParams seek)
cmd' name desc getter setter = noMessages $
command name SectionSetup desc pdesc (withParams seek)
where
pdesc = paramPair paramRemote (paramOptional paramExpression)
@ -35,6 +34,7 @@ cmd' name desc getter setter = command name SectionSetup desc pdesc (withParams
start (rname:[]) = go rname (performGet getter)
start (rname:expr:[]) = go rname $ \uuid -> do
allowMessages
showStart name rname
performSet setter expr uuid
start _ = giveup "Specify a repository."
@ -45,7 +45,6 @@ cmd' name desc getter setter = command name SectionSetup desc pdesc (withParams
performGet :: Ord a => Annex (M.Map a PreferredContentExpression) -> a -> CommandPerform
performGet getter a = do
Annex.setOutput QuietOutput
m <- getter
liftIO $ putStrLn $ fromMaybe "" $ M.lookup a m
next $ return True