cleanup
This commit is contained in:
parent
e7ffa5b594
commit
d7b170c9a2
1 changed files with 7 additions and 6 deletions
13
Commands.hs
13
Commands.hs
|
@ -25,16 +25,17 @@ import qualified Remotes
|
||||||
- actions to be run in the Annex monad. -}
|
- actions to be run in the Annex monad. -}
|
||||||
parseCmd :: [String] -> IO ([Flag], [Annex ()])
|
parseCmd :: [String] -> IO ([Flag], [Annex ()])
|
||||||
parseCmd argv = do
|
parseCmd argv = do
|
||||||
(flags, nonopts) <- getopt
|
(flags, files) <- getopt
|
||||||
case (length nonopts) of
|
case (length files) of
|
||||||
0 -> error header
|
0 -> error header
|
||||||
_ -> do
|
_ -> do
|
||||||
let c = lookupCmd (nonopts !! 0)
|
let c = lookupCmd (files !! 0)
|
||||||
if (0 == length c)
|
if (0 == length c)
|
||||||
then return $ (flags, map defaultCmd nonopts)
|
then ret flags defaultCmd files
|
||||||
else do
|
else ret flags (snd $ c !! 0) $ drop 1 files
|
||||||
return $ (flags, map (snd $ c !! 0) $ drop 1 nonopts)
|
|
||||||
where
|
where
|
||||||
|
ret flags cmd files = return (flags, makeactions cmd files)
|
||||||
|
makeactions cmd files = map cmd files
|
||||||
getopt = case getOpt Permute options argv of
|
getopt = case getOpt Permute options argv of
|
||||||
(flags, nonopts, []) -> return (flags, nonopts)
|
(flags, nonopts, []) -> return (flags, nonopts)
|
||||||
(_, _, errs) -> ioError (userError (concat errs ++ usageInfo header options))
|
(_, _, errs) -> ioError (userError (concat errs ++ usageInfo header options))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue