2013-03-27 17:51:24 +00:00
|
|
|
{- common command-line options
|
2010-12-30 20:52:24 +00:00
|
|
|
-
|
2021-03-22 18:25:28 +00:00
|
|
|
- Copyright 2010-2021 Joey Hess <id@joeyh.name>
|
2010-12-30 20:52:24 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2010-12-30 20:52:24 +00:00
|
|
|
-}
|
|
|
|
|
2021-03-22 18:25:28 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
2015-07-10 20:05:56 +00:00
|
|
|
module CmdLine.Option where
|
2010-12-30 20:52:24 +00:00
|
|
|
|
2015-07-10 04:55:53 +00:00
|
|
|
import Options.Applicative
|
2010-12-30 20:52:24 +00:00
|
|
|
|
2015-07-10 04:55:53 +00:00
|
|
|
import CmdLine.Usage
|
2015-07-10 06:18:08 +00:00
|
|
|
import CmdLine.GlobalSetter
|
2010-12-30 20:52:24 +00:00
|
|
|
import qualified Annex
|
2012-04-27 17:23:52 +00:00
|
|
|
import Types.Messages
|
2015-07-10 04:55:53 +00:00
|
|
|
import Types.DeferredParse
|
2021-03-22 18:25:28 +00:00
|
|
|
import Types.GitConfig
|
|
|
|
import Git.Types (ConfigKey(..))
|
|
|
|
import Git.Config
|
|
|
|
import Utility.FileSystemEncoding
|
2021-04-06 19:14:00 +00:00
|
|
|
import Annex.Debug
|
2010-12-30 20:52:24 +00:00
|
|
|
|
2015-07-10 04:55:53 +00:00
|
|
|
-- Global options accepted by both git-annex and git-annex-shell sub-commands.
|
2015-07-10 17:18:46 +00:00
|
|
|
commonGlobalOptions :: [GlobalOption]
|
2015-07-10 06:03:03 +00:00
|
|
|
commonGlobalOptions =
|
2021-04-06 19:14:00 +00:00
|
|
|
[ globalFlag (setAnnexState $ setforce True)
|
2015-07-10 04:55:53 +00:00
|
|
|
( long "force"
|
|
|
|
<> help "allow actions that may lose annexed data"
|
2015-07-10 06:18:08 +00:00
|
|
|
<> hidden
|
2015-07-10 04:55:53 +00:00
|
|
|
)
|
2021-04-06 19:14:00 +00:00
|
|
|
, globalFlag (setAnnexState $ setfast True)
|
2015-07-10 04:55:53 +00:00
|
|
|
( long "fast" <> short 'F'
|
|
|
|
<> help "avoid slow operations"
|
2015-07-10 06:18:08 +00:00
|
|
|
<> hidden
|
2015-07-10 04:55:53 +00:00
|
|
|
)
|
2021-04-06 19:14:00 +00:00
|
|
|
, globalFlag (setAnnexState $ Annex.setOutput QuietOutput)
|
2015-07-10 04:55:53 +00:00
|
|
|
( long "quiet" <> short 'q'
|
|
|
|
<> help "avoid verbose output"
|
2015-07-10 06:18:08 +00:00
|
|
|
<> hidden
|
2015-07-10 04:55:53 +00:00
|
|
|
)
|
2021-04-06 19:14:00 +00:00
|
|
|
, globalFlag (setAnnexState $ Annex.setOutput NormalOutput)
|
2015-07-10 04:55:53 +00:00
|
|
|
( long "verbose" <> short 'v'
|
|
|
|
<> help "allow verbose output (default)"
|
2015-07-10 06:18:08 +00:00
|
|
|
<> hidden
|
2015-07-10 04:55:53 +00:00
|
|
|
)
|
2021-04-06 19:14:00 +00:00
|
|
|
, globalFlag (setAnnexState $ setdebug True)
|
2015-07-10 04:55:53 +00:00
|
|
|
( long "debug" <> short 'd'
|
|
|
|
<> help "show debug messages"
|
2015-07-10 06:18:08 +00:00
|
|
|
<> hidden
|
2015-07-10 04:55:53 +00:00
|
|
|
)
|
2021-04-06 19:14:00 +00:00
|
|
|
, globalFlag (setAnnexState $ setdebug False)
|
2015-07-10 04:55:53 +00:00
|
|
|
( long "no-debug"
|
|
|
|
<> help "don't show debug messages"
|
2015-07-10 06:18:08 +00:00
|
|
|
<> hidden
|
2015-07-10 04:55:53 +00:00
|
|
|
)
|
2021-04-06 19:14:00 +00:00
|
|
|
, globalOption setdebugfilter $ strOption
|
2021-04-05 19:21:20 +00:00
|
|
|
( long "debugfilter" <> metavar "NAME[,NAME..]"
|
|
|
|
<> help "show debug messages coming from a module"
|
|
|
|
<> hidden
|
|
|
|
)
|
2021-04-06 19:14:00 +00:00
|
|
|
, globalOption setforcebackend $ strOption
|
2015-07-10 04:55:53 +00:00
|
|
|
( long "backend" <> short 'b' <> metavar paramName
|
|
|
|
<> help "specify key-value backend to use"
|
2015-07-10 06:18:08 +00:00
|
|
|
<> hidden
|
2015-07-10 04:55:53 +00:00
|
|
|
)
|
2010-12-31 17:39:30 +00:00
|
|
|
]
|
2012-10-29 01:27:15 +00:00
|
|
|
where
|
|
|
|
setforce v = Annex.changeState $ \s -> s { Annex.force = v }
|
2021-04-06 19:14:00 +00:00
|
|
|
|
2012-10-29 01:27:15 +00:00
|
|
|
setfast v = Annex.changeState $ \s -> s { Annex.fast = v }
|
2021-04-06 19:14:00 +00:00
|
|
|
|
|
|
|
setforcebackend v = setAnnexState $
|
|
|
|
Annex.changeState $ \s -> s { Annex.forcebackend = Just v }
|
|
|
|
|
2021-03-22 18:25:28 +00:00
|
|
|
-- Overriding this way, rather than just setting annexDebug
|
|
|
|
-- makes the config be passed on to any git-annex child processes.
|
2021-04-05 19:21:20 +00:00
|
|
|
setdebug v = Annex.addGitConfigOverride $
|
|
|
|
decodeBS' $ debugconfig <> "=" <> boolConfig' v
|
2021-04-06 19:14:00 +00:00
|
|
|
|
|
|
|
setdebugfilter v = mconcat
|
|
|
|
[ setAnnexRead $ \rd -> rd
|
|
|
|
{ Annex.debugselector = parseDebugSelector v
|
|
|
|
}
|
|
|
|
-- Also set in git config so it will be passed on to any
|
|
|
|
-- git-annex child processes.
|
|
|
|
, setAnnexState $ Annex.addGitConfigOverride $
|
|
|
|
decodeBS' (debugfilterconfig <> "=") ++ v
|
|
|
|
]
|
|
|
|
|
2021-03-22 18:25:28 +00:00
|
|
|
(ConfigKey debugconfig) = annexConfig "debug"
|
2021-04-05 19:21:20 +00:00
|
|
|
(ConfigKey debugfilterconfig) = annexConfig "debugfilter"
|