summaryrefslogtreecommitdiff
path: root/GitAnnexShell.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-02 00:53:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-02 00:53:00 -0400
commitd1f49b0ad032f13adc39d963cc8ceca28215b1d5 (patch)
tree928b469a98f90113822e0300f4c52bd41c6a4863 /GitAnnexShell.hs
parent2d2bfe9809f8d8d5862bc12fbe40c2e25b2405a3 (diff)
add fields to git-annex-shell
Diffstat (limited to 'GitAnnexShell.hs')
-rw-r--r--GitAnnexShell.hs29
1 files changed, 20 insertions, 9 deletions
diff --git a/GitAnnexShell.hs b/GitAnnexShell.hs
index 663303713..2a9f3c26a 100644
--- a/GitAnnexShell.hs
+++ b/GitAnnexShell.hs
@@ -47,7 +47,8 @@ cmds = map adddirparam $ cmds_readonly ++ cmds_notreadonly
options :: [OptDescr (Annex ())]
options = Option.common ++
- [ Option [] ["uuid"] (ReqArg checkuuid paramUUID) "repository uuid"
+ [ Option [] ["uuid"] (ReqArg checkuuid paramUUID) "local repository uuid"
+ , Option [] ["remote-uuid"] (ReqArg checkuuid paramUUID) "remote repository uuid"
]
where
checkuuid expected = getUUID >>= check
@@ -83,21 +84,31 @@ builtins = map cmdname cmds
builtin :: String -> String -> [String] -> IO ()
builtin cmd dir params = do
checkNotReadOnly cmd
- dispatch False (cmd : filterparams params) cmds options header $
+ let (params', fields) = partitionParams params
+ dispatch False (cmd : params') cmds options (parseFields fields) header $
Git.Construct.repoAbsPath dir >>= Git.Construct.fromAbsPath
external :: [String] -> IO ()
external params = do
checkNotLimited
- unlessM (boolSystem "git-shell" $ map Param $ "-c":filterparams params) $
+ unlessM (boolSystem "git-shell" $ map Param $ "-c":fst (partitionParams params)) $
error "git-shell failed"
--- Drop all args after "--".
--- These tend to be passed by rsync and not useful.
-filterparams :: [String] -> [String]
-filterparams [] = []
-filterparams ("--":_) = []
-filterparams (a:as) = a:filterparams as
+{- Parameters between two -- markers are field settings, in the form:
+ - field=value field=value
+ -
+ - Parameters after the last -- are ignored, these tend to be passed by
+ - rsync and not be useful.
+ -}
+partitionParams :: [String] -> ([String], [String])
+partitionParams params
+ | length segments < 2 = (segments !! 0, [])
+ | otherwise = (segments !! 0, segments !! 1)
+ where
+ segments = segment (== "--") params
+
+parseFields :: [String] -> [(String, String)]
+parseFields = map (separate (== '='))
failure :: IO ()
failure = error $ "bad parameters\n\n" ++ usage header cmds options