convert FindRef

This commit is contained in:
Joey Hess 2015-07-10 20:38:11 -04:00
parent 9659052e3f
commit 02f6d9b33a
3 changed files with 11 additions and 12 deletions

View file

@ -57,7 +57,7 @@ import qualified Command.Unlock
import qualified Command.Lock import qualified Command.Lock
import qualified Command.PreCommit import qualified Command.PreCommit
import qualified Command.Find import qualified Command.Find
--import qualified Command.FindRef import qualified Command.FindRef
import qualified Command.Whereis import qualified Command.Whereis
--import qualified Command.List --import qualified Command.List
--import qualified Command.Log --import qualified Command.Log
@ -184,7 +184,7 @@ cmds =
, Command.DropUnused.cmd , Command.DropUnused.cmd
, Command.AddUnused.cmd , Command.AddUnused.cmd
, Command.Find.cmd , Command.Find.cmd
-- , Command.FindRef.cmd , Command.FindRef.cmd
, Command.Whereis.cmd , Command.Whereis.cmd
-- , Command.List.cmd -- , Command.List.cmd
-- , Command.Log.cmd -- , Command.Log.cmd

View file

@ -48,14 +48,14 @@ parseFormatOption =
) )
seek :: FindOptions -> CommandSeek seek :: FindOptions -> CommandSeek
seek o = withFilesInGit (whenAnnexed $ start (formatOption o)) (findThese o) seek o = withFilesInGit (whenAnnexed $ start o) (findThese o)
start :: Maybe Utility.Format.Format -> FilePath -> Key -> CommandStart start :: FindOptions -> FilePath -> Key -> CommandStart
start format file key = do start o file key = do
-- only files inAnnex are shown, unless the user has requested -- only files inAnnex are shown, unless the user has requested
-- others via a limit -- others via a limit
whenM (limited <||> inAnnex key) $ whenM (limited <||> inAnnex key) $
showFormatted format file $ ("file", file) : keyVars key showFormatted (formatOption o) file $ ("file", file) : keyVars key
stop stop
showFormatted :: Maybe Utility.Format.Format -> String -> [(String, String)] -> Annex () showFormatted :: Maybe Utility.Format.Format -> String -> [(String, String)] -> Annex ()

View file

@ -7,16 +7,15 @@
module Command.FindRef where module Command.FindRef where
import Common.Annex
import Command import Command
import qualified Command.Find as Find import qualified Command.Find as Find
cmd :: Command cmd :: Command
cmd = withOptions nonWorkTreeMatchingOptions $ Find.mkCommand $ cmd = withGlobalOptions nonWorkTreeMatchingOptions $ Find.mkCommand $
command "findref" SectionPlumbing command "findref" SectionPlumbing
"lists files in a git ref" "lists files in a git ref"
paramRef (withParams seek) paramRef (seek <$$> Find.optParser)
seek :: CmdParams -> CommandSeek seek :: Find.FindOptions -> CommandSeek
seek refs = do seek o = Find.start o `withFilesInRefs` Find.findThese o
format <- Find.getFormat
Find.start format `withFilesInRefs` refs