diff options
author | Joey Hess <joey@kitenet.net> | 2011-12-22 18:31:44 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-12-22 18:31:44 -0400 |
commit | 06bafae9e016b4d65c023546516e51bd32b08649 (patch) | |
tree | 25ec8e4ed7a2ebcb5363df4284df8c690c30e1fe /Command | |
parent | cf496f09ab3777cc4ffe601e876b432dc320bd12 (diff) |
Format strings can be specified using the new --find option, to control what is output by git annex find.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Find.hs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Command/Find.hs b/Command/Find.hs index 47058fa25..6050ff7bb 100644 --- a/Command/Find.hs +++ b/Command/Find.hs @@ -7,11 +7,16 @@ module Command.Find where +import qualified Data.Map as M + import Common.Annex import Command import Annex.Content import Limit import qualified Annex +import qualified Utility.Format +import Utility.DataUnits +import Types.Key def :: [Command] def = [command "find" paramPaths seek "lists available files"] @@ -24,8 +29,18 @@ start file (key, _) = do -- only files inAnnex are shown, unless the user has requested -- others via a limit whenM (liftM2 (||) (inAnnex key) limited) $ do - print0 <- Annex.getState Annex.print0 - if print0 - then liftIO $ putStr (file ++ "\0") - else liftIO $ putStrLn file + f <- Annex.getState Annex.format + case f of + Nothing -> liftIO $ putStrLn file + Just formatter -> liftIO $ putStr $ + Utility.Format.format formatter vars stop + where + vars = M.fromList + [ ("file", file) + , ("key", show key) + , ("backend", keyBackendName key) + , ("bytesize", size show) + , ("humansize", size $ roughSize storageUnits True) + ] + size c = maybe "unknown" c $ keySize key |