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. -}
|
- functions. -}
|
||||||
type CommandSeekStrings = CommandStartString -> CommandSeek
|
type CommandSeekStrings = CommandStartString -> CommandSeek
|
||||||
type CommandStartString = String -> CommandStart
|
type CommandStartString = String -> CommandStart
|
||||||
|
type CommandSeekWords = CommandStartWords -> CommandSeek
|
||||||
|
type CommandStartWords = [String] -> CommandStart
|
||||||
type CommandSeekKeys = CommandStartKey -> CommandSeek
|
type CommandSeekKeys = CommandStartKey -> CommandSeek
|
||||||
type CommandStartKey = Key -> CommandStart
|
type CommandStartKey = Key -> CommandStart
|
||||||
type BackendFile = (FilePath, Maybe (Backend Annex))
|
type BackendFile = (FilePath, Maybe (Backend Annex))
|
||||||
|
@ -143,8 +145,8 @@ withFilesNotInGit a params = do
|
||||||
newfiles <- liftIO $ runPreserveOrder (Git.notInRepo repo) params
|
newfiles <- liftIO $ runPreserveOrder (Git.notInRepo repo) params
|
||||||
newfiles' <- filterFiles newfiles
|
newfiles' <- filterFiles newfiles
|
||||||
backendPairs a newfiles'
|
backendPairs a newfiles'
|
||||||
withString :: CommandSeekStrings
|
withWords :: CommandSeekWords
|
||||||
withString a params = return [a $ unwords params]
|
withWords a params = return [a params]
|
||||||
withStrings :: CommandSeekStrings
|
withStrings :: CommandSeekStrings
|
||||||
withStrings a params = return $ map a params
|
withStrings a params = return $ map a params
|
||||||
withFilesToBeCommitted :: CommandSeekStrings
|
withFilesToBeCommitted :: CommandSeekStrings
|
||||||
|
|
|
@ -18,12 +18,12 @@ command = [repoCommand "describe" (paramPair paramRemote paramDesc) seek
|
||||||
"change description of a repository"]
|
"change description of a repository"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withString start]
|
seek = [withWords start]
|
||||||
|
|
||||||
start :: CommandStartString
|
start :: CommandStartWords
|
||||||
start params = notBareRepo $ do
|
start ws = notBareRepo $ do
|
||||||
let (name, description) =
|
let (name, description) =
|
||||||
case (words params) of
|
case ws of
|
||||||
(n:d) -> (n,unwords d)
|
(n:d) -> (n,unwords d)
|
||||||
_ -> error "Specify a repository and a description."
|
_ -> error "Specify a repository and a description."
|
||||||
|
|
||||||
|
|
|
@ -27,15 +27,17 @@ command = [repoCommand "init" paramDesc seek
|
||||||
"initialize git-annex with repository description"]
|
"initialize git-annex with repository description"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withString start]
|
seek = [withWords start]
|
||||||
|
|
||||||
{- Stores description for the repository etc. -}
|
{- Stores description for the repository etc. -}
|
||||||
start :: CommandStartString
|
start :: CommandStartWords
|
||||||
start description = do
|
start ws = do
|
||||||
when (null description) $
|
when (null description) $
|
||||||
error "please specify a description of this repository\n"
|
error "please specify a description of this repository\n"
|
||||||
showStart "init" description
|
showStart "init" description
|
||||||
next $ perform description
|
next $ perform description
|
||||||
|
where
|
||||||
|
description = unwords ws
|
||||||
|
|
||||||
perform :: String -> CommandPerform
|
perform :: String -> CommandPerform
|
||||||
perform description = do
|
perform description = do
|
||||||
|
|
|
@ -28,21 +28,22 @@ command = [repoCommand "initremote"
|
||||||
"sets up a special (non-git) remote"]
|
"sets up a special (non-git) remote"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withString start]
|
seek = [withWords start]
|
||||||
|
|
||||||
start :: CommandStartString
|
start :: CommandStartWords
|
||||||
start params = notBareRepo $ do
|
start ws = notBareRepo $ do
|
||||||
when (null ws) $ error "Specify a name for the remote"
|
when (null ws) $ error "Specify a name for the remote"
|
||||||
|
|
||||||
(u, c) <- findByName name
|
(u, c) <- findByName name
|
||||||
let fullconfig = M.union config c
|
let fullconfig = M.union config c
|
||||||
t <- findType fullconfig
|
t <- findType fullconfig
|
||||||
|
|
||||||
|
liftIO $ putStrLn $ show fullconfig
|
||||||
|
|
||||||
showStart "initremote" name
|
showStart "initremote" name
|
||||||
next $ perform t u $ M.union config c
|
next $ perform t u $ M.union config c
|
||||||
|
|
||||||
where
|
where
|
||||||
ws = words params
|
|
||||||
name = head ws
|
name = head ws
|
||||||
config = Remote.keyValToConfig $ tail ws
|
config = Remote.keyValToConfig $ tail ws
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,11 @@ command = [repoCommand "semitrust" (paramRepeating paramRemote) seek
|
||||||
"return repository to default trust level"]
|
"return repository to default trust level"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withString start]
|
seek = [withWords start]
|
||||||
|
|
||||||
start :: CommandStartString
|
start :: CommandStartWords
|
||||||
start name = notBareRepo $ do
|
start ws = notBareRepo $ do
|
||||||
|
let name = unwords ws
|
||||||
showStart "semitrust" name
|
showStart "semitrust" name
|
||||||
u <- Remote.nameToUUID name
|
u <- Remote.nameToUUID name
|
||||||
next $ perform u
|
next $ perform u
|
||||||
|
|
|
@ -18,10 +18,11 @@ command = [repoCommand "trust" (paramRepeating paramRemote) seek
|
||||||
"trust a repository"]
|
"trust a repository"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withString start]
|
seek = [withWords start]
|
||||||
|
|
||||||
start :: CommandStartString
|
start :: CommandStartWords
|
||||||
start name = notBareRepo $ do
|
start ws = notBareRepo $ do
|
||||||
|
let name = unwords ws
|
||||||
showStart "trust" name
|
showStart "trust" name
|
||||||
u <- Remote.nameToUUID name
|
u <- Remote.nameToUUID name
|
||||||
next $ perform u
|
next $ perform u
|
||||||
|
|
|
@ -18,10 +18,11 @@ command = [repoCommand "untrust" (paramRepeating paramRemote) seek
|
||||||
"do not trust a repository"]
|
"do not trust a repository"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withString start]
|
seek = [withWords start]
|
||||||
|
|
||||||
start :: CommandStartString
|
start :: CommandStartWords
|
||||||
start name = notBareRepo $ do
|
start ws = notBareRepo $ do
|
||||||
|
let name = unwords ws
|
||||||
showStart "untrust" name
|
showStart "untrust" name
|
||||||
u <- Remote.nameToUUID name
|
u <- Remote.nameToUUID name
|
||||||
next $ perform u
|
next $ perform u
|
||||||
|
|
Loading…
Reference in a new issue