diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-06-16 16:50:03 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-06-16 16:50:03 -0400 |
commit | 712deee42b122f0ec07866e6bd7770343cee971c (patch) | |
tree | 4eb2525edc3cf17d2f6710c7ce52eb28d423f28b /CmdLine | |
parent | c9d9fca2ed950b32be992d5ac2a055c8246f52a5 (diff) |
sync: Add support for --all and --unused.
Diffstat (limited to 'CmdLine')
-rw-r--r-- | CmdLine/GitAnnex/Options.hs | 16 | ||||
-rw-r--r-- | CmdLine/Seek.hs | 20 |
2 files changed, 22 insertions, 14 deletions
diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs index 46d593618..320268f6a 100644 --- a/CmdLine/GitAnnex/Options.hs +++ b/CmdLine/GitAnnex/Options.hs @@ -53,13 +53,15 @@ gitAnnexOptions = commonOptions ++ -- Options for matching on annexed keys, rather than work tree files. 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" - , keyOption - ] +keyOptions = [ allOption, unusedOption, keyOption] + +allOption :: Option +allOption = Option ['A'] ["all"] (NoArg (Annex.setFlag "all")) + "operate on all versions of all files" + +unusedOption :: Option +unusedOption = Option ['U'] ["unused"] (NoArg (Annex.setFlag "unused")) + "operate on files found by last run of git-annex unused" keyOption :: Option keyOption = Option [] ["key"] (ReqArg (Annex.setField "key") paramKey) diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs index 664c12b62..47e2c79bc 100644 --- a/CmdLine/Seek.hs +++ b/CmdLine/Seek.hs @@ -4,7 +4,7 @@ - the values a user passes to a command, and prepare actions operating - on them. - - - Copyright 2010-2014 Joey Hess <id@joeyh.name> + - Copyright 2010-2015 Joey Hess <id@joeyh.name> - - Licensed under the GNU GPL version 3 or higher. -} @@ -172,7 +172,17 @@ withNothing _ _ = error "This command takes no parameters." - Otherwise falls back to a regular CommandSeek action on - whatever params were passed. -} withKeyOptions :: Bool -> (Key -> CommandStart) -> CommandSeek -> CommandSeek -withKeyOptions auto keyop fallbackop params = do +withKeyOptions auto keyop = withKeyOptions' auto $ \getkeys -> do + matcher <- Limit.getMatcher + seekActions $ map (process matcher) <$> getkeys + where + process matcher k = ifM (matcher $ MatchingKey k) + ( keyop k + , return Nothing + ) + +withKeyOptions' :: Bool -> (Annex [Key] -> Annex ()) -> CommandSeek -> CommandSeek +withKeyOptions' auto keyop fallbackop params = do bare <- fromRepo Git.repoIsLocalBare allkeys <- Annex.getFlag "all" unused <- Annex.getFlag "unused" @@ -194,11 +204,7 @@ withKeyOptions auto keyop fallbackop params = do _ -> error "Can only specify one of file names, --all, --unused, --key, or --incomplete" where go True _ = error "Cannot use --auto with --all or --unused or --key or --incomplete" - go False a = do - matcher <- Limit.getMatcher - seekActions $ map (process matcher) <$> a - process matcher k = ifM (matcher $ MatchingKey k) - ( keyop k , return Nothing) + go False getkeys = keyop getkeys incompletekeys = staleKeysPrune gitAnnexTmpObjectDir True prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart] |