diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-25 19:17:11 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-25 19:17:11 -0400 |
commit | e87287c11b81ea6f339628bcbebfb239d0ccadd0 (patch) | |
tree | 7ee01405715834e473b9874b9eeb87968d5d0d65 /Commands.hs | |
parent | 47892ced883b96c3a9c2903aa8a59b3b8a2f1731 (diff) |
fix failure propigation
Diffstat (limited to 'Commands.hs')
-rw-r--r-- | Commands.hs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/Commands.hs b/Commands.hs index 78e1ab32c..729eae124 100644 --- a/Commands.hs +++ b/Commands.hs @@ -42,21 +42,27 @@ type SubCmdPerform = Annex (Maybe SubCmdCleanup) type SubCmdCleanup = Annex Bool {- Runs a subcommand through its three stages. -} -doSubCmd :: String -> SubCmdStart -> String -> Annex () +doSubCmd :: String -> SubCmdStart -> String -> Annex Bool doSubCmd cmdname start param = do res <- start param :: Annex (Maybe SubCmdPerform) case (res) of - Nothing -> return () + Nothing -> return True Just perform -> do showStart cmdname param res <- perform :: Annex (Maybe SubCmdCleanup) case (res) of - Nothing -> showEndFail + Nothing -> do + showEndFail + return False Just cleanup -> do res <- cleanup if (res) - then showEndOk - else showEndFail + then do + showEndOk + return True + else do + showEndFail + return False {- A subcommand can broadly want one of several kinds of input parameters. @@ -159,7 +165,7 @@ findWanted Keys params _ = return params - run in the Annex monad. The first actions configure it - according to command line options, while the second actions - handle subcommands. -} -parseCmd :: [String] -> AnnexState -> IO ([Annex ()], [Annex ()]) +parseCmd :: [String] -> AnnexState -> IO ([Annex Bool], [Annex Bool]) parseCmd argv state = do (flags, params) <- getopt if (null params) @@ -169,8 +175,12 @@ parseCmd argv state = do [Command name action want _] -> do f <- findWanted want (drop 1 params) (TypeInternals.repo state) - return (flags, map (doSubCmd name action) $ - filter notstate f) + let actions = map (doSubCmd name action) $ + filter notstate f + let configactions = map (\f -> do + f + return True) flags + return (configactions, actions) where -- never include files from the state directory notstate f = stateLoc /= take (length stateLoc) f |