blob: 22fbe60ca3ca591fb422d4eec5ff7a0ed09719a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
{- git-annex main program
- -}
import System.IO
import System.Environment
import Control.Exception
import CmdLine
import Annex
main = do
args <- getArgs
(mode, files) <- argvToMode args
state <- startAnnex
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 ()
|