summaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-10 13:18:46 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-10 13:23:06 -0400
commit19a3a331c35238a10ec2c537cf64d0b4c1fb290c (patch)
treeca5d79d0be1a80c01c9ad452331bdbebc1c4430a /CmdLine
parent9886c302ef538e538ec7d48b94374b9d2400004f (diff)
finished converting all the main options
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/GitAnnex.hs8
-rw-r--r--CmdLine/GitAnnex/Options.hs170
-rw-r--r--CmdLine/GitAnnexShell.hs2
-rw-r--r--CmdLine/GlobalSetter.hs8
-rw-r--r--CmdLine/Option.hs2
5 files changed, 116 insertions, 74 deletions
diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs
index d2411ffb4..18964d4dd 100644
--- a/CmdLine/GitAnnex.hs
+++ b/CmdLine/GitAnnex.hs
@@ -60,7 +60,7 @@ import qualified Command.Find
--import qualified Command.FindRef
--import qualified Command.Whereis
--import qualified Command.List
-import qualified Command.Log
+--import qualified Command.Log
import qualified Command.Merge
import qualified Command.ResolveMerge
--import qualified Command.Info
@@ -87,7 +87,7 @@ import qualified Command.AddUrl
import qualified Command.ImportFeed
#endif
import qualified Command.RmUrl
-import qualified Command.Import
+--import qualified Command.Import
import qualified Command.Map
import qualified Command.Direct
import qualified Command.Indirect
@@ -136,7 +136,7 @@ cmds =
, Command.ImportFeed.cmd
#endif
, Command.RmUrl.cmd
- , Command.Import.cmd
+-- , Command.Import.cmd
, Command.Init.cmd
, Command.Describe.cmd
, Command.InitRemote.cmd
@@ -187,7 +187,7 @@ cmds =
-- , Command.FindRef.cmd
-- , Command.Whereis.cmd
-- , Command.List.cmd
- , Command.Log.cmd
+-- , Command.Log.cmd
, Command.Merge.cmd
, Command.ResolveMerge.cmd
-- , Command.Info.cmd
diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs
index 9f033aa4d..f95a4d03e 100644
--- a/CmdLine/GitAnnex/Options.hs
+++ b/CmdLine/GitAnnex/Options.hs
@@ -7,7 +7,6 @@
module CmdLine.GitAnnex.Options where
-import System.Console.GetOpt
import Options.Applicative
import Common.Annex
@@ -30,7 +29,7 @@ import CmdLine.GlobalSetter
-- Global options that are accepted by all git-annex sub-commands,
-- although not always used.
-gitAnnexGlobalOptions :: [Parser GlobalSetter]
+gitAnnexGlobalOptions :: [GlobalOption]
gitAnnexGlobalOptions = commonGlobalOptions ++
[ globalSetter setnumcopies $ option auto
( long "numcopies" <> short 'N' <> metavar paramNumber
@@ -86,6 +85,20 @@ gitAnnexGlobalOptions = commonGlobalOptions ++
>>= Annex.changeGitRepo
setdesktopnotify v = Annex.changeState $ \s -> s { Annex.desktopnotify = Annex.desktopnotify s <> v }
+{- Parser that accepts all non-option params. -}
+cmdParams :: CmdParamsDesc -> Parser CmdParams
+cmdParams paramdesc = many $ argument str
+ ( metavar paramdesc
+ -- Let bash completion complete files
+ <> action "file"
+ )
+
+parseAutoOption :: Parser Bool
+parseAutoOption = switch
+ ( long "auto" <> short 'a'
+ <> help "automatic mode"
+ )
+
parseRemoteOption :: Parser RemoteName -> Parser (DeferredParse Remote)
parseRemoteOption p = DeferredParse . (fromJust <$$> Remote.byNameWithUUID) . Just <$> p
@@ -150,96 +163,125 @@ parseKey :: Monad m => String -> m Key
parseKey = maybe (fail "invalid key") return . file2key
-- Options to match properties of annexed files.
-annexedMatchingOptions :: [Option]
+annexedMatchingOptions :: [GlobalOption]
annexedMatchingOptions = concat
[ nonWorkTreeMatchingOptions'
, fileMatchingOptions'
- -- , combiningOptions
- -- , [timeLimitOption]
+ , combiningOptions
+ , [timeLimitOption]
]
-- Matching options that don't need to examine work tree files.
-nonWorkTreeMatchingOptions :: [Option]
-nonWorkTreeMatchingOptions = nonWorkTreeMatchingOptions' -- ++ combiningOptions
+nonWorkTreeMatchingOptions :: [GlobalOption]
+nonWorkTreeMatchingOptions = nonWorkTreeMatchingOptions' ++ combiningOptions
-nonWorkTreeMatchingOptions' :: [Option]
+nonWorkTreeMatchingOptions' :: [GlobalOption]
nonWorkTreeMatchingOptions' =
- [ Option ['i'] ["in"] (ReqArg Limit.addIn paramRemote)
- "match files present in a remote"
- , Option ['C'] ["copies"] (ReqArg Limit.addCopies paramNumber)
- "skip files with fewer copies"
- , Option [] ["lackingcopies"] (ReqArg (Limit.addLackingCopies False) paramNumber)
- "match files that need more copies"
- , Option [] ["approxlackingcopies"] (ReqArg (Limit.addLackingCopies True) paramNumber)
- "match files that need more copies (faster)"
- , Option ['B'] ["inbackend"] (ReqArg Limit.addInBackend paramName)
- "match files using a key-value backend"
- , Option [] ["inallgroup"] (ReqArg Limit.addInAllGroup paramGroup)
- "match files present in all remotes in a group"
- , Option [] ["metadata"] (ReqArg Limit.addMetaData "FIELD=VALUE")
- "match files with attached metadata"
- , Option [] ["want-get"] (NoArg Limit.Wanted.addWantGet)
- "match files the repository wants to get"
- , Option [] ["want-drop"] (NoArg Limit.Wanted.addWantDrop)
- "match files the repository wants to drop"
+ [ globalSetter Limit.addIn $ strOption
+ ( long "in" <> short 'i' <> metavar paramRemote
+ <> help "match files present in a remote"
+ <> hidden
+ )
+ , globalSetter Limit.addCopies $ strOption
+ ( long "copies" <> short 'C' <> metavar paramRemote
+ <> help "skip files with fewer copies"
+ <> hidden
+ )
+ , globalSetter (Limit.addLackingCopies False) $ strOption
+ ( long "lackingcopies" <> metavar paramNumber
+ <> help "match files that need more copies"
+ <> hidden
+ )
+ , globalSetter (Limit.addLackingCopies True) $ strOption
+ ( long "approxlackingcopies" <> metavar paramNumber
+ <> help "match files that need more copies (faster)"
+ <> hidden
+ )
+ , globalSetter Limit.addInBackend $ strOption
+ ( long "inbackend" <> short 'B' <> metavar paramName
+ <> help "match files using a key-value backend"
+ <> hidden
+ )
+ , globalSetter Limit.addInAllGroup $ strOption
+ ( long "inallgroup" <> metavar paramGroup
+ <> help "match files present in all remotes in a group"
+ <> hidden
+ )
+ , globalSetter Limit.addMetaData $ strOption
+ ( long "metadata" <> metavar "FIELD=VALUE"
+ <> help "match files with attached metadata"
+ <> hidden
+ )
+ , globalFlag Limit.Wanted.addWantGet
+ ( long "want-get"
+ <> help "match files the repository wants to get"
+ <> hidden
+ )
+ , globalFlag Limit.Wanted.addWantDrop
+ ( long "want-drop"
+ <> help "match files the repository wants to drop"
+ <> hidden
+ )
]
-- Options to match files which may not yet be annexed.
-fileMatchingOptions :: [Option]
-fileMatchingOptions = fileMatchingOptions' -- ++ combiningOptions
+fileMatchingOptions :: [GlobalOption]
+fileMatchingOptions = fileMatchingOptions' ++ combiningOptions
-fileMatchingOptions' :: [Option]
+fileMatchingOptions' :: [GlobalOption]
fileMatchingOptions' =
- [ Option ['x'] ["exclude"] (ReqArg Limit.addExclude paramGlob)
- "skip files matching the glob pattern"
- , Option ['I'] ["include"] (ReqArg Limit.addInclude paramGlob)
- "limit to files matching the glob pattern"
- , Option [] ["largerthan"] (ReqArg Limit.addLargerThan paramSize)
- "match files larger than a size"
- , Option [] ["smallerthan"] (ReqArg Limit.addSmallerThan paramSize)
- "match files smaller than a size"
+ [ globalSetter Limit.addExclude $ strOption
+ ( long "exclude" <> short 'x' <> metavar paramGlob
+ <> help "skip files matching the glob pattern"
+ <> hidden
+ )
+ , globalSetter Limit.addInclude $ strOption
+ ( long "include" <> short 'I' <> metavar paramGlob
+ <> help "limit to files matching the glob pattern"
+ <> hidden
+ )
+ , globalSetter Limit.addLargerThan $ strOption
+ ( long "largerthan" <> metavar paramSize
+ <> help "match files larger than a size"
+ <> hidden
+ )
+ , globalSetter Limit.addSmallerThan $ strOption
+ ( long "smallerthan" <> metavar paramSize
+ <> help "match files smaller than a size"
+ <> hidden
+ )
]
-combiningOptions :: Parser [GlobalSetter]
+combiningOptions :: [GlobalOption]
combiningOptions =
- many $ longopt "not" "negate next option"
- <|> longopt "and" "both previous and next option must match"
- <|> longopt "or" "either previous or next option must match"
- <|> shortopt '(' "open group of options"
- <|> shortopt ')' "close group of options"
+ [ longopt "not" "negate next option"
+ , longopt "and" "both previous and next option must match"
+ , longopt "or" "either previous or next option must match"
+ , shortopt '(' "open group of options"
+ , shortopt ')' "close group of options"
+ ]
where
- longopt o h = globalFlag (Limit.addToken o) ( long o <> help h )
- shortopt o h = globalFlag (Limit.addToken [o]) ( short o <> help h)
+ longopt o h = globalFlag (Limit.addToken o) ( long o <> help h <> hidden )
+ shortopt o h = globalFlag (Limit.addToken [o]) ( short o <> help h <> hidden )
-jsonOption :: Parser GlobalSetter
+jsonOption :: GlobalOption
jsonOption = globalFlag (Annex.setOutput JSONOutput)
( long "json" <> short 'j'
<> help "enable JSON output"
+ <> hidden
)
-parseJobsOption :: Parser GlobalSetter
-parseJobsOption = globalSetter (Annex.setOutput . ParallelOutput) $
+jobsOption :: GlobalOption
+jobsOption = globalSetter (Annex.setOutput . ParallelOutput) $
option auto
( long "jobs" <> short 'J' <> metavar paramNumber
<> help "enable concurrent jobs"
+ <> hidden
)
-parseTimeLimitOption :: Parser GlobalSetter
-parseTimeLimitOption = globalSetter Limit.addTimeLimit $ strOption
+timeLimitOption :: GlobalOption
+timeLimitOption = globalSetter Limit.addTimeLimit $ strOption
( long "time-limit" <> short 'T' <> metavar paramTime
<> help "stop after the specified amount of time"
- )
-
-parseAutoOption :: Parser Bool
-parseAutoOption = switch
- ( long "auto" <> short 'a'
- <> help "automatic mode"
- )
-
-{- Parser that accepts all non-option params. -}
-cmdParams :: CmdParamsDesc -> Parser CmdParams
-cmdParams paramdesc = many $ argument str
- ( metavar paramdesc
- -- Let bash completion complete files
- <> action "file"
+ <> hidden
)
diff --git a/CmdLine/GitAnnexShell.hs b/CmdLine/GitAnnexShell.hs
index c1d02a702..074257ac5 100644
--- a/CmdLine/GitAnnexShell.hs
+++ b/CmdLine/GitAnnexShell.hs
@@ -54,7 +54,7 @@ cmds = map adddirparam $ cmds_readonly ++ cmds_notreadonly
where
adddirparam c = c { cmdparamdesc = "DIRECTORY " ++ cmdparamdesc c }
-globalOptions :: [Parser GlobalSetter]
+globalOptions :: [GlobalOption]
globalOptions =
globalSetter checkUUID (strOption
( long "uuid" <> metavar paramUUID
diff --git a/CmdLine/GlobalSetter.hs b/CmdLine/GlobalSetter.hs
index eb73f3f12..831a8b440 100644
--- a/CmdLine/GlobalSetter.hs
+++ b/CmdLine/GlobalSetter.hs
@@ -13,12 +13,12 @@ import Annex
import Options.Applicative
-globalFlag :: Annex () -> Mod FlagFields GlobalSetter -> Parser GlobalSetter
+globalFlag :: Annex () -> Mod FlagFields GlobalSetter -> GlobalOption
globalFlag setter = flag' (DeferredParse setter)
-globalSetter :: (v -> Annex ()) -> Parser v -> Parser GlobalSetter
+globalSetter :: (v -> Annex ()) -> Parser v -> GlobalOption
globalSetter setter parser = DeferredParse . setter <$> parser
-combineGlobalSetters :: [Parser GlobalSetter] -> Parser GlobalSetter
-combineGlobalSetters l = DeferredParse . sequence_ . map getParsed
+combineGlobalOptions :: [GlobalOption] -> Parser GlobalSetter
+combineGlobalOptions l = DeferredParse . sequence_ . map getParsed
<$> many (foldl1 (<|>) l)
diff --git a/CmdLine/Option.hs b/CmdLine/Option.hs
index 9cc7a1f4b..9f2353f98 100644
--- a/CmdLine/Option.hs
+++ b/CmdLine/Option.hs
@@ -26,7 +26,7 @@ import Types.Messages
import Types.DeferredParse
-- Global options accepted by both git-annex and git-annex-shell sub-commands.
-commonGlobalOptions :: [Parser GlobalSetter]
+commonGlobalOptions :: [GlobalOption]
commonGlobalOptions =
[ globalFlag (setforce True)
( long "force"