2013-03-27 17:51:24 +00:00
|
|
|
{- git-annex options
|
|
|
|
-
|
|
|
|
- Copyright 2010, 2013 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module GitAnnex.Options where
|
|
|
|
|
|
|
|
import System.Console.GetOpt
|
|
|
|
|
|
|
|
import Common.Annex
|
|
|
|
import qualified Git.Config
|
|
|
|
import Command
|
|
|
|
import Types.TrustLevel
|
|
|
|
import qualified Annex
|
|
|
|
import qualified Remote
|
|
|
|
import qualified Limit
|
2013-10-28 18:50:17 +00:00
|
|
|
import qualified Limit.Wanted
|
2013-03-27 17:51:24 +00:00
|
|
|
import qualified Option
|
|
|
|
|
|
|
|
options :: [Option]
|
|
|
|
options = Option.common ++
|
|
|
|
[ Option ['N'] ["numcopies"] (ReqArg setnumcopies paramNumber)
|
|
|
|
"override default number of copies"
|
|
|
|
, Option [] ["trust"] (trustArg Trusted)
|
|
|
|
"override trust setting"
|
|
|
|
, Option [] ["semitrust"] (trustArg SemiTrusted)
|
|
|
|
"override trust setting back to default"
|
|
|
|
, Option [] ["untrust"] (trustArg UnTrusted)
|
|
|
|
"override trust setting to untrusted"
|
|
|
|
, Option ['c'] ["config"] (ReqArg setgitconfig "NAME=VALUE")
|
|
|
|
"override git configuration setting"
|
|
|
|
, Option ['x'] ["exclude"] (ReqArg Limit.addExclude paramGlob)
|
|
|
|
"skip files matching the glob pattern"
|
|
|
|
, Option ['I'] ["include"] (ReqArg Limit.addInclude paramGlob)
|
2013-10-28 18:50:17 +00:00
|
|
|
"limit to files matching the glob pattern"
|
2013-03-27 17:51:24 +00:00
|
|
|
, Option ['i'] ["in"] (ReqArg Limit.addIn paramRemote)
|
2013-10-28 18:50:17 +00:00
|
|
|
"match files present in a remote"
|
2013-03-27 17:51:24 +00:00
|
|
|
, Option ['C'] ["copies"] (ReqArg Limit.addCopies paramNumber)
|
|
|
|
"skip files with fewer copies"
|
|
|
|
, Option ['B'] ["inbackend"] (ReqArg Limit.addInBackend paramName)
|
2013-10-28 18:50:17 +00:00
|
|
|
"match files using a key-value backend"
|
2013-03-27 17:51:24 +00:00
|
|
|
, Option [] ["inallgroup"] (ReqArg Limit.addInAllGroup paramGroup)
|
2013-10-28 18:50:17 +00:00
|
|
|
"match files present in all remotes in a group"
|
2013-03-27 17:51:24 +00:00
|
|
|
, Option [] ["largerthan"] (ReqArg Limit.addLargerThan paramSize)
|
2013-10-28 18:50:17 +00:00
|
|
|
"match files larger than a size"
|
2013-03-27 17:51:24 +00:00
|
|
|
, Option [] ["smallerthan"] (ReqArg Limit.addSmallerThan paramSize)
|
2013-10-28 18:50:17 +00:00
|
|
|
"match files smaller than a size"
|
|
|
|
, Option [] ["want-get"] (NoArg Limit.Wanted.addWantGet)
|
2013-10-28 18:51:51 +00:00
|
|
|
"match files the repository wants to get"
|
2013-10-28 18:50:17 +00:00
|
|
|
, Option [] ["want-drop"] (NoArg Limit.Wanted.addWantDrop)
|
2013-10-28 18:51:51 +00:00
|
|
|
"match files the repository wants to drop"
|
2013-03-27 17:51:24 +00:00
|
|
|
, Option ['T'] ["time-limit"] (ReqArg Limit.addTimeLimit paramTime)
|
|
|
|
"stop after the specified amount of time"
|
2013-09-28 18:35:21 +00:00
|
|
|
, Option [] ["user-agent"] (ReqArg setuseragent paramName)
|
|
|
|
"override default User-Agent"
|
2013-03-27 17:51:24 +00:00
|
|
|
, Option [] ["trust-glacier"] (NoArg (Annex.setFlag "trustglacier"))
|
|
|
|
"Trust Amazon Glacier inventory"
|
|
|
|
] ++ Option.matcher
|
|
|
|
where
|
|
|
|
setnumcopies v = maybe noop
|
2013-07-09 16:05:56 +00:00
|
|
|
(\n -> Annex.changeState $ \s -> s { Annex.forcenumcopies = Just n })
|
2013-03-27 17:51:24 +00:00
|
|
|
(readish v)
|
2013-09-28 18:35:21 +00:00
|
|
|
setuseragent v = Annex.changeState $ \s -> s { Annex.useragent = Just v }
|
2013-03-27 17:51:24 +00:00
|
|
|
setgitconfig v = Annex.changeGitRepo =<< inRepo (Git.Config.store v)
|
|
|
|
trustArg t = ReqArg (Remote.forceTrust t) paramRemote
|
2013-07-03 17:02:42 +00:00
|
|
|
|
2013-07-03 19:26:59 +00:00
|
|
|
keyOptions :: [Option]
|
|
|
|
keyOptions =
|
|
|
|
[ Option ['A'] ["all"] (NoArg (Annex.setFlag "all"))
|
|
|
|
"operate on all versions of all files"
|
|
|
|
, Option ['U'] ["unused"] (NoArg (Annex.setFlag "unused"))
|
|
|
|
"operate on files found by last run of git-annex unused"
|
|
|
|
]
|
2013-08-20 19:46:35 +00:00
|
|
|
|
|
|
|
fromOption :: Option
|
|
|
|
fromOption = Option.field ['f'] "from" paramRemote "source remote"
|
|
|
|
|
|
|
|
toOption :: Option
|
|
|
|
toOption = Option.field ['t'] "to" paramRemote "destination remote"
|
|
|
|
|
|
|
|
fromToOptions :: [Option]
|
|
|
|
fromToOptions = [fromOption, toOption]
|