summaryrefslogtreecommitdiff
path: root/Commands.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-16 13:38:59 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-16 13:38:59 -0400
commit1260adbd7700ab9e35f61f4ad94b9cc0536f243e (patch)
treec94583f697832cb4f16af6222bd63bd25d80461d /Commands.hs
parent645bc94d3d9e5f08bda74a99e0584768b32da81c (diff)
basic recursion done; skipping git stuff still todo
Diffstat (limited to 'Commands.hs')
-rw-r--r--Commands.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/Commands.hs b/Commands.hs
index a403a5a48..f28b3e72b 100644
--- a/Commands.hs
+++ b/Commands.hs
@@ -26,20 +26,21 @@ import qualified Remotes
- actions to be run in the Annex monad. -}
parseCmd :: [String] -> IO ([Flag], [Annex ()])
parseCmd argv = do
- (flags, files) <- getopt
- case (length files) of
+ (flags, params) <- getopt
+ case (length params) of
0 -> error header
_ -> do
- let c = lookupCmd (files !! 0)
- if (0 == length c)
- then ret flags defaultCmd files
- else ret flags (snd $ c !! 0) $ drop 1 files
+ let (cmd, locs) = takeCmd params $ lookupCmd (params !! 0)
+ files <- mapM recurseFiles locs
+ return (flags, map cmd $ foldl (++) [] files)
where
- ret flags cmd files = return (flags, makeactions cmd files)
- makeactions cmd files = map cmd files
getopt = case getOpt Permute options argv of
(flags, nonopts, []) -> return (flags, nonopts)
(_, _, errs) -> ioError (userError (concat errs ++ usageInfo header options))
+ takeCmd files cmds =
+ if (0 == length cmds)
+ then (defaultCmd, files)
+ else ((snd $ cmds !! 0), drop 1 files)
lookupCmd cmd = filter (\(c, a) -> c == cmd) cmds
cmds = [ ("add", addCmd)
, ("get", getCmd)