From ceff04ff3e7fff4b0ea6e8ad4334cca80d291880 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 16 May 2011 12:25:54 -0400 Subject: better multiword parameter handling This way, individual words as entered on the command line are available to commands. --- Command/Describe.hs | 8 ++++---- Command/Init.hs | 8 +++++--- Command/InitRemote.hs | 9 +++++---- Command/Semitrust.hs | 7 ++++--- Command/Trust.hs | 7 ++++--- Command/Untrust.hs | 7 ++++--- 6 files changed, 26 insertions(+), 20 deletions(-) (limited to 'Command') 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 -- cgit v1.2.3