summaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/GitAnnex/Options.hs10
-rw-r--r--CmdLine/GitAnnexShell.hs1
-rw-r--r--CmdLine/GlobalSetter.hs24
-rw-r--r--CmdLine/Option.hs8
4 files changed, 43 insertions, 0 deletions
diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs
index bb002a103..6965e8e51 100644
--- a/CmdLine/GitAnnex/Options.hs
+++ b/CmdLine/GitAnnex/Options.hs
@@ -26,6 +26,7 @@ import qualified Limit
import qualified Limit.Wanted
import CmdLine.Option
import CmdLine.Usage
+import CmdLine.GlobalSetter
-- Global options that are accepted by all git-annex sub-commands,
-- although not always used.
@@ -34,38 +35,47 @@ gitAnnexGlobalOptions = commonGlobalOptions ++
[ globalSetter setnumcopies $ option auto
( long "numcopies" <> short 'N' <> metavar paramNumber
<> help "override default number of copies"
+ <> hidden
)
, globalSetter (Remote.forceTrust Trusted) $ strOption
( long "trust" <> metavar paramRemote
<> help "override trust setting"
+ <> hidden
)
, globalSetter (Remote.forceTrust SemiTrusted) $ strOption
( long "semitrust" <> metavar paramRemote
<> help "override trust setting back to default"
+ <> hidden
)
, globalSetter (Remote.forceTrust UnTrusted) $ strOption
( long "untrust" <> metavar paramRemote
<> help "override trust setting to untrusted"
+ <> hidden
)
, globalSetter setgitconfig $ strOption
( long "config" <> short 'c' <> metavar "NAME=VALUE"
<> help "override git configuration setting"
+ <> hidden
)
, globalSetter setuseragent $ strOption
( long "user-agent" <> metavar paramName
<> help "override default User-Agent"
+ <> hidden
)
, globalFlag (Annex.setFlag "trustglacier")
( long "trust-glacier"
<> help "Trust Amazon Glacier inventory"
+ <> hidden
)
, globalFlag (setdesktopnotify mkNotifyFinish)
( long "notify-finish"
<> help "show desktop notification after transfer finishes"
+ <> hidden
)
, globalFlag (setdesktopnotify mkNotifyStart)
( long "notify-start"
<> help "show desktop notification after transfer completes"
+ <> hidden
)
]
where
diff --git a/CmdLine/GitAnnexShell.hs b/CmdLine/GitAnnexShell.hs
index c653e8626..c1d02a702 100644
--- a/CmdLine/GitAnnexShell.hs
+++ b/CmdLine/GitAnnexShell.hs
@@ -13,6 +13,7 @@ import Common.Annex
import qualified Git.Construct
import qualified Git.Config
import CmdLine
+import CmdLine.GlobalSetter
import Command
import Annex.UUID
import CmdLine.GitAnnexShell.Fields
diff --git a/CmdLine/GlobalSetter.hs b/CmdLine/GlobalSetter.hs
new file mode 100644
index 000000000..eb73f3f12
--- /dev/null
+++ b/CmdLine/GlobalSetter.hs
@@ -0,0 +1,24 @@
+{- git-annex global options
+ -
+ - Copyright 2015 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module CmdLine.GlobalSetter where
+
+import Types.DeferredParse
+import Common
+import Annex
+
+import Options.Applicative
+
+globalFlag :: Annex () -> Mod FlagFields GlobalSetter -> Parser GlobalSetter
+globalFlag setter = flag' (DeferredParse setter)
+
+globalSetter :: (v -> Annex ()) -> Parser v -> Parser GlobalSetter
+globalSetter setter parser = DeferredParse . setter <$> parser
+
+combineGlobalSetters :: [Parser GlobalSetter] -> Parser GlobalSetter
+combineGlobalSetters l = DeferredParse . sequence_ . map getParsed
+ <$> many (foldl1 (<|>) l)
diff --git a/CmdLine/Option.hs b/CmdLine/Option.hs
index d28c7a704..9cc7a1f4b 100644
--- a/CmdLine/Option.hs
+++ b/CmdLine/Option.hs
@@ -20,6 +20,7 @@ import System.Console.GetOpt
import Common.Annex
import CmdLine.Usage
+import CmdLine.GlobalSetter
import qualified Annex
import Types.Messages
import Types.DeferredParse
@@ -30,30 +31,37 @@ commonGlobalOptions =
[ globalFlag (setforce True)
( long "force"
<> help "allow actions that may lose annexed data"
+ <> hidden
)
, globalFlag (setfast True)
( long "fast" <> short 'F'
<> help "avoid slow operations"
+ <> hidden
)
, globalFlag (Annex.setOutput QuietOutput)
( long "quiet" <> short 'q'
<> help "avoid verbose output"
+ <> hidden
)
, globalFlag (Annex.setOutput NormalOutput)
( long "verbose" <> short 'v'
<> help "allow verbose output (default)"
+ <> hidden
)
, globalFlag setdebug
( long "debug" <> short 'd'
<> help "show debug messages"
+ <> hidden
)
, globalFlag unsetdebug
( long "no-debug"
<> help "don't show debug messages"
+ <> hidden
)
, globalSetter setforcebackend $ strOption
( long "backend" <> short 'b' <> metavar paramName
<> help "specify key-value backend to use"
+ <> hidden
)
]
where