better multiword parameter handling
This way, individual words as entered on the command line are available to commands.
This commit is contained in:
parent
8fa17eaba0
commit
ceff04ff3e
7 changed files with 30 additions and 22 deletions
|
@ -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
|
||||
|
|
|
@ -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."
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue