Format strings can be specified using the new --find option, to control what is output by git annex find.
This commit is contained in:
parent
cf496f09ab
commit
06bafae9e0
7 changed files with 47 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue