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
|
2013-11-05 17:38:37 +00:00
|
|
|
import Git.Types
|
2013-03-27 17:51:24 +00:00
|
|
|
import Command
|
|
|
|
import Types.TrustLevel
|
2014-01-21 20:08:19 +00:00
|
|
|
import Types.NumCopies
|
2014-01-18 15:54:43 +00:00
|
|
|
import Types.Messages
|
2013-03-27 17:51:24 +00:00
|
|
|
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"
|
2014-01-21 22:46:39 +00:00
|
|
|
, Option [] ["lackingcopies"] (ReqArg (Limit.addLackingCopies False) paramNumber)
|
Add and use numcopiesneeded preferred content expression.
* Add numcopiesneeded preferred content expression.
* Client, transfer, incremental backup, and archive repositories
now want to get content that does not yet have enough copies.
This means the asssistant will make copies of files that don't yet
meet the configured numcopies, even to places that would not normally want
the file.
For example, if numcopies is 4, and there are 2 client repos and
2 transfer repos, and 2 removable backup drives, the file will be sent
to both transfer repos in order to make 4 copies. Once a removable drive
get a copy of the file, it will be dropped from one transfer repo or the
other (but not both).
Another example, numcopies is 3 and there is a client that has a backup
removable drive and two small archive repos. Normally once one of the small
archives has a file, it will not be put into the other one. But, to satisfy
numcopies, the assistant will duplicate it into the other small archive
too, if the backup repo is not available to receive the file.
I notice that these examples are fairly unlikely setups .. the old behavior
was not too bad, but it's nice to finally have it really correct.
.. Almost. I have skipped checking the annex.numcopies .gitattributes
out of fear it will be too slow.
This commit was sponsored by Florian Schlegel.
2014-01-20 21:34:58 +00:00
|
|
|
"match files that need more copies"
|
2014-01-21 22:46:39 +00:00
|
|
|
, Option [] ["approxlackingcopies"] (ReqArg (Limit.addLackingCopies True) paramNumber)
|
|
|
|
"match files that need more copies (faster)"
|
2013-03-27 17:51:24 +00:00
|
|
|
, 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
|
2013-11-05 17:38:37 +00:00
|
|
|
trustArg t = ReqArg (Remote.forceTrust t) paramRemote
|
2013-03-27 17:51:24 +00:00
|
|
|
setnumcopies v = maybe noop
|
2014-01-21 21:08:49 +00:00
|
|
|
(\n -> Annex.changeState $ \s -> s { Annex.forcenumcopies = Just $ NumCopies 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-11-05 17:38:37 +00:00
|
|
|
setgitconfig v = inRepo (Git.Config.store v)
|
|
|
|
>>= pure . (\r -> r { gitGlobalOpts = gitGlobalOpts r ++ [Param "-c", Param v] })
|
|
|
|
>>= Annex.changeGitRepo
|
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"
|
2014-01-26 18:59:47 +00:00
|
|
|
, Option [] ["key"] (ReqArg (Annex.setField "key") paramKey)
|
|
|
|
"operate on specified key"
|
2013-07-03 19:26:59 +00:00
|
|
|
]
|
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]
|
2014-01-18 15:54:43 +00:00
|
|
|
|
|
|
|
jsonOption :: Option
|
|
|
|
jsonOption = Option ['j'] ["json"] (NoArg (Annex.setOutput JSONOutput))
|
|
|
|
"enable JSON output"
|