contentlocationn: New plumbing command.
This commit is contained in:
parent
b22aacab44
commit
ce0a82f493
8 changed files with 84 additions and 0 deletions
32
Command/ContentLocation.hs
Normal file
32
Command/ContentLocation.hs
Normal file
|
@ -0,0 +1,32 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2015 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Command.ContentLocation where
|
||||
|
||||
import Common.Annex
|
||||
import Command
|
||||
import Annex.Content
|
||||
import Types.Key
|
||||
|
||||
cmd :: [Command]
|
||||
cmd = [noCommit $ noMessages $
|
||||
command "contentlocation" (paramRepeating paramKey) seek
|
||||
SectionPlumbing "looks up content for a key"]
|
||||
|
||||
seek :: CommandSeek
|
||||
seek = withKeys start
|
||||
|
||||
start :: Key -> CommandStart
|
||||
start k = do
|
||||
liftIO . maybe exitFailure putStrLn
|
||||
=<< inAnnex' (pure True) Nothing check k
|
||||
stop
|
||||
where
|
||||
check f = ifM (liftIO (doesFileExist f))
|
||||
( return (Just f)
|
||||
, return Nothing
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue