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
|
|
|
|
2022-06-29 17:28:08 +00:00
|
|
|
import CmdLine.AnnexSetter
|
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
|
|
|
|
2022-06-29 17:28:08 +00:00
|
|
|
-- Options accepted by both git-annex and git-annex-shell sub-commands.
|
|
|
|
commonOptions :: [AnnexOption]
|
|
|
|
commonOptions =
|
|
|
|
[ annexFlag (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
|
|
|
)
|
2022-06-29 17:28:08 +00:00
|
|
|
, annexFlag (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
|
|
|
)
|
2022-06-29 17:28:08 +00:00
|
|
|
, annexFlag (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
|
|
|
)
|
2022-06-29 17:28:08 +00:00
|
|
|
, annexFlag (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
|
|
|
)
|
2022-06-29 17:28:08 +00:00
|
|
|
, annexFlag (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
|
|
|
)
|
2022-06-29 17:28:08 +00:00
|
|
|
, annexFlag (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
|
|
|
)
|
2022-06-29 17:28:08 +00:00
|
|
|
, annexOption setdebugfilter $ strOption
|
2021-04-05 19:21:20 +00:00
|
|
|
( long "debugfilter" <> metavar "NAME[,NAME..]"
|
2023-05-17 16:38:22 +00:00
|
|
|
<> help "show debug messages coming from the specified module"
|
2021-04-05 19:21:20 +00:00
|
|
|
<> hidden
|
|
|
|
)
|
2010-12-31 17:39:30 +00:00
|
|
|
]
|
2012-10-29 01:27:15 +00:00
|
|
|
where
|
2022-06-28 19:28:14 +00:00
|
|
|
setforce v = setAnnexRead $ \rd -> rd { Annex.force = v }
|
2021-04-06 19:14:00 +00:00
|
|
|
|
2022-06-28 19:28:14 +00:00
|
|
|
setfast v = setAnnexRead $ \rd -> rd { Annex.fast = v }
|
2021-04-06 19:14:00 +00:00
|
|
|
|
2021-04-06 20:28:37 +00:00
|
|
|
setdebug v = mconcat
|
|
|
|
[ setAnnexRead $ \rd -> rd { Annex.debugenabled = v }
|
|
|
|
-- Also set in git config so it will be passed on to any
|
|
|
|
-- git-annex child processes.
|
|
|
|
, setAnnexState $ Annex.addGitConfigOverride $
|
2021-08-11 00:45:02 +00:00
|
|
|
decodeBS $ debugconfig <> "=" <> boolConfig' v
|
2021-04-06 20:28:37 +00:00
|
|
|
]
|
2021-04-06 19:14:00 +00:00
|
|
|
|
|
|
|
setdebugfilter v = mconcat
|
|
|
|
[ setAnnexRead $ \rd -> rd
|
2021-04-06 20:28:37 +00:00
|
|
|
{ Annex.debugselector = parseDebugSelector v }
|
2021-04-06 19:14:00 +00:00
|
|
|
-- Also set in git config so it will be passed on to any
|
|
|
|
-- git-annex child processes.
|
|
|
|
, setAnnexState $ Annex.addGitConfigOverride $
|
2021-08-11 00:45:02 +00:00
|
|
|
decodeBS (debugfilterconfig <> "=") ++ v
|
2021-04-06 19:14:00 +00:00
|
|
|
]
|
|
|
|
|
2021-03-22 18:25:28 +00:00
|
|
|
(ConfigKey debugconfig) = annexConfig "debug"
|
2021-04-05 19:21:20 +00:00
|
|
|
(ConfigKey debugfilterconfig) = annexConfig "debugfilter"
|