summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-16 12:25:54 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-16 12:25:54 -0400
commitceff04ff3e7fff4b0ea6e8ad4334cca80d291880 (patch)
treee0e7296c82dc30b8e6dab1024a645d29a5c69b36
parent8fa17eaba08b99250d6290915379f048844d83d7 (diff)
better multiword parameter handling
This way, individual words as entered on the command line are available to commands.
-rw-r--r--Command.hs6
-rw-r--r--Command/Describe.hs8
-rw-r--r--Command/Init.hs8
-rw-r--r--Command/InitRemote.hs9
-rw-r--r--Command/Semitrust.hs7
-rw-r--r--Command/Trust.hs7
-rw-r--r--Command/Untrust.hs7
7 files changed, 30 insertions, 22 deletions
diff --git a/Command.hs b/Command.hs
index 4f835a3ad..abbe897b5 100644
--- a/Command.hs
+++ b/Command.hs
@@ -47,6 +47,8 @@ type CommandCleanup = Annex Bool
- functions. -}
type CommandSeekStrings = CommandStartString -> CommandSeek
type CommandStartString = String -> CommandStart
+type CommandSeekWords = CommandStartWords -> CommandSeek
+type CommandStartWords = [String] -> CommandStart
type CommandSeekKeys = CommandStartKey -> CommandSeek
type CommandStartKey = Key -> CommandStart
type BackendFile = (FilePath, Maybe (Backend Annex))
@@ -143,8 +145,8 @@ withFilesNotInGit a params = do
newfiles <- liftIO $ runPreserveOrder (Git.notInRepo repo) params
newfiles' <- filterFiles newfiles
backendPairs a newfiles'
-withString :: CommandSeekStrings
-withString a params = return [a $ unwords params]
+withWords :: CommandSeekWords
+withWords a params = return [a params]
withStrings :: CommandSeekStrings
withStrings a params = return $ map a params
withFilesToBeCommitted :: CommandSeekStrings
diff --git a/Command/Describe.hs b/Command/Describe.hs
index dcabef7fb..57f884e03 100644
--- a/Command/Describe.hs
+++ b/Command/Describe.hs
@@ -18,12 +18,12 @@ command = [repoCommand "describe" (paramPair paramRemote paramDesc) seek
"change description of a repository"]
seek :: [CommandSeek]
-seek = [withString start]
+seek = [withWords start]
-start :: CommandStartString
-start params = notBareRepo $ do
+start :: CommandStartWords
+start ws = notBareRepo $ do
let (name, description) =
- case (words params) of
+ case ws of
(n:d) -> (n,unwords d)
_ -> error "Specify a repository and a description."
diff --git a/Command/Init.hs b/Command/Init.hs
index 668b5c87d..b7a078799 100644
--- a/Command/Init.hs
+++ b/Command/Init.hs
@@ -27,15 +27,17 @@ command = [repoCommand "init" paramDesc seek
"initialize git-annex with repository description"]
seek :: [CommandSeek]
-seek = [withString start]
+seek = [withWords start]
{- Stores description for the repository etc. -}
-start :: CommandStartString
-start description = do
+start :: CommandStartWords
+start ws = do
when (null description) $
error "please specify a description of this repository\n"
showStart "init" description
next $ perform description
+ where
+ description = unwords ws
perform :: String -> CommandPerform
perform description = do
diff --git a/Command/InitRemote.hs b/Command/InitRemote.hs
index 261ccdc8b..ae22e3564 100644
--- a/Command/InitRemote.hs
+++ b/Command/InitRemote.hs
@@ -28,21 +28,22 @@ command = [repoCommand "initremote"
"sets up a special (non-git) remote"]
seek :: [CommandSeek]
-seek = [withString start]
+seek = [withWords start]
-start :: CommandStartString
-start params = notBareRepo $ do
+start :: CommandStartWords
+start ws = notBareRepo $ do
when (null ws) $ error "Specify a name for the remote"
(u, c) <- findByName name
let fullconfig = M.union config c
t <- findType fullconfig
+ liftIO $ putStrLn $ show fullconfig
+
showStart "initremote" name
next $ perform t u $ M.union config c
where
- ws = words params
name = head ws
config = Remote.keyValToConfig $ tail ws
diff --git a/Command/Semitrust.hs b/Command/Semitrust.hs
index fc1bcbbcd..11742137f 100644
--- a/Command/Semitrust.hs
+++ b/Command/Semitrust.hs
@@ -18,10 +18,11 @@ command = [repoCommand "semitrust" (paramRepeating paramRemote) seek
"return repository to default trust level"]
seek :: [CommandSeek]
-seek = [withString start]
+seek = [withWords start]
-start :: CommandStartString
-start name = notBareRepo $ do
+start :: CommandStartWords
+start ws = notBareRepo $ do
+ let name = unwords ws
showStart "semitrust" name
u <- Remote.nameToUUID name
next $ perform u
diff --git a/Command/Trust.hs b/Command/Trust.hs
index ef03828c2..d5444affe 100644
--- a/Command/Trust.hs
+++ b/Command/Trust.hs
@@ -18,10 +18,11 @@ command = [repoCommand "trust" (paramRepeating paramRemote) seek
"trust a repository"]
seek :: [CommandSeek]
-seek = [withString start]
+seek = [withWords start]
-start :: CommandStartString
-start name = notBareRepo $ do
+start :: CommandStartWords
+start ws = notBareRepo $ do
+ let name = unwords ws
showStart "trust" name
u <- Remote.nameToUUID name
next $ perform u
diff --git a/Command/Untrust.hs b/Command/Untrust.hs
index ebe9c31b3..174c39506 100644
--- a/Command/Untrust.hs
+++ b/Command/Untrust.hs
@@ -18,10 +18,11 @@ command = [repoCommand "untrust" (paramRepeating paramRemote) seek
"do not trust a repository"]
seek :: [CommandSeek]
-seek = [withString start]
+seek = [withWords start]
-start :: CommandStartString
-start name = notBareRepo $ do
+start :: CommandStartWords
+start ws = notBareRepo $ do
+ let name = unwords ws
showStart "untrust" name
u <- Remote.nameToUUID name
next $ perform u