summaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-10 02:03:03 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-10 02:03:03 -0400
commitccd76ebf641ad481e549da97c85f73101a3149fd (patch)
tree254f0d644e4998ff73046de74fa4fa4f91735ec8 /CmdLine
parent56c0bf6c690ffddc4ac561393f4cd21d087b7ddb (diff)
wired up global options
Note that I ran into a problem where parsing the global options looped forever, eating memory. It was somehow caused by stacking combineGlobalSetters inside a combineGlobalSetters. Maybe due to both using "many"? Anyway, changed things to avoid that.
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/GitAnnex/Options.hs7
-rw-r--r--CmdLine/GitAnnexShell.hs13
-rw-r--r--CmdLine/Option.hs4
3 files changed, 11 insertions, 13 deletions
diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs
index 8bc96a14d..bb002a103 100644
--- a/CmdLine/GitAnnex/Options.hs
+++ b/CmdLine/GitAnnex/Options.hs
@@ -29,10 +29,9 @@ import CmdLine.Usage
-- Global options that are accepted by all git-annex sub-commands,
-- although not always used.
-gitAnnexGlobalOptions :: Parser GlobalSetter
-gitAnnexGlobalOptions = globalSetters
- [ commonGlobalOptions
- , globalSetter setnumcopies $ option auto
+gitAnnexGlobalOptions :: [Parser GlobalSetter]
+gitAnnexGlobalOptions = commonGlobalOptions ++
+ [ globalSetter setnumcopies $ option auto
( long "numcopies" <> short 'N' <> metavar paramNumber
<> help "override default number of copies"
)
diff --git a/CmdLine/GitAnnexShell.hs b/CmdLine/GitAnnexShell.hs
index 5bc297a71..c653e8626 100644
--- a/CmdLine/GitAnnexShell.hs
+++ b/CmdLine/GitAnnexShell.hs
@@ -53,14 +53,13 @@ cmds = map adddirparam $ cmds_readonly ++ cmds_notreadonly
where
adddirparam c = c { cmdparamdesc = "DIRECTORY " ++ cmdparamdesc c }
-options :: Parser GlobalSetter
-options = globalSetters
- [ commonGlobalOptions
- , globalSetter checkUUID $ strOption
+globalOptions :: [Parser GlobalSetter]
+globalOptions =
+ globalSetter checkUUID (strOption
( long "uuid" <> metavar paramUUID
<> help "local repository uuid"
- )
- ]
+ ))
+ : commonGlobalOptions
where
checkUUID expected = getUUID >>= check
where
@@ -101,7 +100,7 @@ builtin cmd dir params = do
let (params', fieldparams, opts) = partitionParams params
rsyncopts = ("RsyncOptions", unwords opts)
fields = rsyncopts : filter checkField (parseFields fieldparams)
- dispatch False (cmd : params') cmds options fields mkrepo
+ dispatch False (cmd : params') cmds globalOptions fields mkrepo
"git-annex-shell"
"Restricted login shell for git-annex only SSH access"
where
diff --git a/CmdLine/Option.hs b/CmdLine/Option.hs
index 9cb1d41d4..d28c7a704 100644
--- a/CmdLine/Option.hs
+++ b/CmdLine/Option.hs
@@ -25,8 +25,8 @@ import Types.Messages
import Types.DeferredParse
-- Global options accepted by both git-annex and git-annex-shell sub-commands.
-commonGlobalOptions :: Parser GlobalSetter
-commonGlobalOptions = globalSetters
+commonGlobalOptions :: [Parser GlobalSetter]
+commonGlobalOptions =
[ globalFlag (setforce True)
( long "force"
<> help "allow actions that may lose annexed data"