7f7ae7a3b1
It would be nice if command-specific options were supported. The first difficulty is that which command is being called is not known until after getopt; but that could be worked around by finding the first non-dashed parameter. Storing the settings without putting them in the annex monad is the next difficulty; it could perhaps be handled by making the seek stage pass applicable settings into the start stage (and from there on to perform as needed). But that still leaves a problem, what data type to use to represent the options between getopt and seek?
31 lines
744 B
Haskell
31 lines
744 B
Haskell
{- git-annex command
|
|
-
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
-
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
-}
|
|
|
|
module Command.Find where
|
|
|
|
import Common.Annex
|
|
import Command
|
|
import Annex.Content
|
|
import Limit
|
|
import qualified Annex
|
|
|
|
def :: [Command]
|
|
def = [command "find" paramPaths seek "lists available files"]
|
|
|
|
seek :: [CommandSeek]
|
|
seek = [withFilesInGit $ whenAnnexed start]
|
|
|
|
start :: FilePath -> (Key, Backend Annex) -> CommandStart
|
|
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
|
|
stop
|