From ad43f0362688a601ba43f462e80f5a91bf398c02 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 5 Jan 2012 22:48:59 -0400 Subject: per-command options Finally commands can define their own options. Moved --format and --print0 to be options only of find. --- Command/Find.hs | 9 +++++++-- Command/Status.hs | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'Command') diff --git a/Command/Find.hs b/Command/Find.hs index 0c96369ee..c86db5fa6 100644 --- a/Command/Find.hs +++ b/Command/Find.hs @@ -1,6 +1,6 @@ {- git-annex command - - - Copyright 2010 Joey Hess + - Copyright 2010-2012 Joey Hess - - 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] diff --git a/Command/Status.hs b/Command/Status.hs index 736d897ef..d2d8d4c07 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -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) -- cgit v1.2.3