File: Option.hs

package info (click to toggle)
git-annex 10.20251029-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 75,300 kB
  • sloc: haskell: 91,492; javascript: 9,103; sh: 1,593; makefile: 216; perl: 137; ansic: 44
file content (95 lines) | stat: -rw-r--r-- 2,504 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{- common command-line options
 -
 - Copyright 2010-2021 Joey Hess <id@joeyh.name>
 -
 - Licensed under the GNU AGPL version 3 or higher.
 -}

{-# LANGUAGE OverloadedStrings #-}

module CmdLine.Option where

import Options.Applicative

import CmdLine.AnnexSetter
import qualified Annex
import Types.Messages
import Types.DeferredParse
import Types.GitConfig
import Git.Types (ConfigKey(..))
import Git.Config
import Utility.FileSystemEncoding
import Annex.Debug

-- Options accepted by both git-annex and git-annex-shell sub-commands.
commonOptions :: [AnnexOption]
commonOptions =
	[ annexFlag (setforce True)
		( long "force" 
		<> help "allow actions that may lose annexed data"
		<> hidden
		)
	, annexFlag (setfast True)
		( long "fast" <> short 'F'
		<> help "avoid slow operations"
		<> hidden
		)
	, annexFlag (setAnnexState $ Annex.setOutput QuietOutput)
		( long "quiet" <> short 'q'
		<> help "avoid verbose output"
		<> hidden
		)
	, annexFlag (setAnnexState $ Annex.setOutput NormalOutput)
		( long "verbose" <> short 'v'
		<> help "allow verbose output (default)"
		<> hidden
		)
	, annexFlag (setdebug True)
		( long "debug" <> short 'd'
		<> help "show debug messages"
		<> hidden
		)
	, annexFlag (setdebug False)
		( long "no-debug"
		<> help "don't show debug messages"
		<> hidden
		)
	, annexOption setdebugfilter $ strOption
		( long "debugfilter" <> metavar "NAME[,NAME..]"
		<> help "show debug messages coming from the specified module"
		<> hidden
		)
	, annexFlag (setexplain True)
		( long "explain" <> short 'd'
		<> help "explain why git-annex does what it does"
		<> hidden
		)
	]
  where
	setforce v = setAnnexRead $ \rd -> rd { Annex.force = v }

	setfast v = setAnnexRead $ \rd -> rd { Annex.fast = v }

	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 $
			decodeBS $ debugconfig <> "=" <> boolConfig' v
		]
	
	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
		]
	
	setexplain v = mconcat
		[ setAnnexRead $ \rd -> rd { Annex.explainenabled = v }
		]
	
	(ConfigKey debugconfig) = annexConfig "debug"
	(ConfigKey debugfilterconfig) = annexConfig "debugfilter"