summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Daniel Brooks <db48x@db48x.net>2016-12-05 09:59:20 -0500
committerGravatar Daniel Brooks <db48x@db48x.net>2016-12-05 09:59:20 -0500
commit31bbf7577aa17d4af44714526ab7651c74369a36 (patch)
tree9d3d0fcfb674acd6146adda54491d381caffad05
parentc6970ef134cdc376fad48fbd8eb79c562d434e7c (diff)
git-annex fromkey now takes multiple pairs of keys and filenames
It also still reads from stdin when none are specified.
-rw-r--r--Command/FromKey.hs15
-rw-r--r--doc/git-annex-fromkey.mdwn8
2 files changed, 14 insertions, 9 deletions
diff --git a/Command/FromKey.hs b/Command/FromKey.hs
index 670e9e6a6..0916cf79d 100644
--- a/Command/FromKey.hs
+++ b/Command/FromKey.hs
@@ -20,16 +20,18 @@ import Network.URI
cmd :: Command
cmd = notDirect $ notBareRepo $
command "fromkey" SectionPlumbing "adds a file using a specific key"
- (paramPair paramKey paramPath)
+ (paramRepeating (paramPair paramKey paramPath))
(withParams seek)
seek :: CmdParams -> CommandSeek
+seek [] = do
+ withNothing startMass []
seek ps = do
force <- Annex.getState Annex.force
- withWords (start force) ps
+ withPairs (start force) ps
-start :: Bool -> [String] -> CommandStart
-start force (keyname:file:[]) = do
+start :: Bool -> (String, FilePath) -> CommandStart
+start force (keyname, file) = do
let key = mkKey keyname
unless force $ do
inbackend <- inAnnex key
@@ -37,10 +39,11 @@ start force (keyname:file:[]) = do
"key ("++ keyname ++") is not present in backend (use --force to override this sanity check)"
showStart "fromkey" file
next $ perform key file
-start _ [] = do
+
+startMass :: CommandStart
+startMass = do
showStart "fromkey" "stdin"
next massAdd
-start _ _ = giveup "specify a key and a dest file"
massAdd :: CommandPerform
massAdd = go True =<< map (separate (== ' ')) . lines <$> liftIO getContents
diff --git a/doc/git-annex-fromkey.mdwn b/doc/git-annex-fromkey.mdwn
index 461f42eb6..2591e9785 100644
--- a/doc/git-annex-fromkey.mdwn
+++ b/doc/git-annex-fromkey.mdwn
@@ -4,14 +4,16 @@ git-annex fromkey - adds a file using a specific key
# SYNOPSIS
-git annex fromkey `[key file]`
+git annex fromkey `[key file ...]`
# DESCRIPTION
This plumbing-level command can be used to manually set up a file
in the git repository to link to a specified key.
-If the key and file are not specified on the command line, they are
+Multiple pairs of file and key can be given in a single command line.
+
+If no key and file pair are specified on the command line, they are
instead read from stdin. Any number of lines can be provided in this
mode, each containing a key and filename, separated by a single space.
@@ -26,7 +28,7 @@ to do that.
* `--force`
Allow making a file link to a key whose content is not in the local
- repository. The key may not be known to git-annex at all.
+ repository. The key may not be known to git-annex at all.
# SEE ALSO