8e5ea28c26
The hoped for optimisation of CommandStart with -J did not materialize. In fact, not runnign CommandStart in parallel is slower than -J3. So, CommandStart are still run in parallel. (The actual bad performance I've been seeing with -J in my big repo has to do with building the remoteList.) But, this is still progress toward making -J faster, because it gets rid of the onlyActionOn roadblock in the way of making CommandCleanup jobs run separate from CommandPerform jobs. Added OnlyActionOn constructor for ActionItem which fixes the onlyActionOn breakage in the last commit. Made CustomOutput include an ActionItem, so even things using it can specify OnlyActionOn. In Command.Move and Command.Sync, there were CommandStarts that used includeCommandAction, so output messages, which is no longer allowed. Fixed by using startingCustomOutput, but that's still not quite right, since it prevents message display for the includeCommandAction run inside it too.
66 lines
1.6 KiB
Haskell
66 lines
1.6 KiB
Haskell
{- git-annex command
|
|
-
|
|
- Copyright 2017 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
module Command.Config where
|
|
|
|
import Command
|
|
import Logs.Config
|
|
import Config
|
|
|
|
cmd :: Command
|
|
cmd = noMessages $ command "config" SectionSetup
|
|
"configuration stored in git-annex branch"
|
|
paramNothing (seek <$$> optParser)
|
|
|
|
data Action
|
|
= SetConfig ConfigName ConfigValue
|
|
| GetConfig ConfigName
|
|
| UnsetConfig ConfigName
|
|
|
|
type Name = String
|
|
type Value = String
|
|
|
|
optParser :: CmdParamsDesc -> Parser Action
|
|
optParser _ = setconfig <|> getconfig <|> unsetconfig
|
|
where
|
|
setconfig = SetConfig
|
|
<$> strOption
|
|
( long "set"
|
|
<> help "set configuration"
|
|
<> metavar paramName
|
|
)
|
|
<*> strArgument
|
|
( metavar paramValue
|
|
)
|
|
getconfig = GetConfig <$> strOption
|
|
( long "get"
|
|
<> help "get configuration"
|
|
<> metavar paramName
|
|
)
|
|
unsetconfig = UnsetConfig <$> strOption
|
|
( long "unset"
|
|
<> help "unset configuration"
|
|
<> metavar paramName
|
|
)
|
|
|
|
seek :: Action -> CommandSeek
|
|
seek (SetConfig name val) = commandAction $
|
|
startingUsualMessages name (ActionItemOther (Just val)) $ do
|
|
setGlobalConfig name val
|
|
setConfig (ConfigKey name) val
|
|
next $ return True
|
|
seek (UnsetConfig name) = commandAction $
|
|
startingUsualMessages name (ActionItemOther (Just "unset")) $do
|
|
unsetGlobalConfig name
|
|
unsetConfig (ConfigKey name)
|
|
next $ return True
|
|
seek (GetConfig name) = commandAction $
|
|
startingCustomOutput (ActionItemOther Nothing) $ do
|
|
getGlobalConfig name >>= \case
|
|
Nothing -> return ()
|
|
Just v -> liftIO $ putStrLn v
|
|
next $ return True
|