summaryrefslogtreecommitdiff
path: root/git-annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-10 21:00:42 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-10 21:00:42 -0400
commit200bc6fdb84658593bfb02f34f984531b6710d26 (patch)
tree7361961de5e90c8be6d1a56010214304cdd18659 /git-annex.hs
parent344f13394fe5b12cbdd5eeb99bb63892c7096bfd (diff)
better option handling
multiple-file support for all modes
Diffstat (limited to 'git-annex.hs')
-rw-r--r--git-annex.hs29
1 files changed, 25 insertions, 4 deletions
diff --git a/git-annex.hs b/git-annex.hs
index 2c9b1315f..22fbe60ca 100644
--- a/git-annex.hs
+++ b/git-annex.hs
@@ -1,16 +1,37 @@
{- git-annex main program
- -}
+import System.IO
import System.Environment
-import GitRepo
+import Control.Exception
import CmdLine
import Annex
-import BackendList
main = do
args <- getArgs
- flags <- argvToFlags args
+ (mode, files) <- argvToMode args
state <- startAnnex
- mapM (\f -> dispatch f state) flags
+ tryRun 0 $ map (\f -> dispatch state mode f) files
+
+{- Tries to run a series of actions, not stopping if some error out,
+ - and propigating an overall error status at the end. -}
+tryRun errflag [] = do
+ if (errflag > 0)
+ then error "unsuccessful"
+ else return ()
+tryRun errflag (a:as) = do
+ result <- try (a)::IO (Either SomeException ())
+ case (result) of
+ Left err -> do
+ showErr err
+ tryRun 1 as
+ Right _ -> tryRun errflag as
+
+{- Exception pretty-printing. -}
+showErr :: SomeException -> IO ()
+showErr e = do
+ let err = show e
+ hPutStrLn stderr $ "git-annex: " ++ err
+ return ()