per-command options

Finally commands can define their own options.

Moved --format and --print0 to be options only of find.
This commit is contained in:
Joey Hess 2012-01-05 22:48:59 -04:00
parent 47be4383b7
commit ad43f03626
9 changed files with 162 additions and 87 deletions

View file

@ -1,6 +1,6 @@
{- git-annex command
-
- Copyright 2010 Joey Hess <joey@kitenet.net>
- Copyright 2010-2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@ -19,7 +19,12 @@ import Utility.DataUnits
import Types.Key
def :: [Command]
def = [command "find" paramPaths seek "lists available files"]
def = [withOptions [formatOption, print0Option] $
command "find" paramPaths seek "lists available files"]
print0Option :: Option
print0Option = Option [] ["print0"] (NoArg $ setFormat "${file}\0")
"terminate output with null"
seek :: [CommandSeek]
seek = [withFilesInGit $ whenAnnexed start]

View file

@ -144,9 +144,9 @@ bad_data_size = staleSize "bad keys size" gitAnnexBadDir
backend_usage :: Stat
backend_usage = stat "backend usage" $ nojson $
usage <$> cachedKeysReferenced <*> cachedKeysPresent
calc <$> cachedKeysReferenced <*> cachedKeysPresent
where
usage a b = pp "" $ reverse . sort $ map swap $ splits $ S.toList $ S.union a b
calc a b = pp "" $ reverse . sort $ map swap $ splits $ S.toList $ S.union a b
splits :: [Key] -> [(String, Integer)]
splits ks = M.toList $ M.fromListWith (+) $ map tcount ks
tcount k = (keyBackendName k, 1)