blob: 7bcd4de2268747bc21e218eeefe314f0964d1a3e (
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 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 errnum oknum [] = do
if (errnum > 0)
then error $ (show errnum) ++ " failed ; " ++ show (oknum) ++ " ok"
else return ()
tryRun errnum oknum (a:as) = do
result <- try (a)::IO (Either SomeException ())
case (result) of
Left err -> do
showErr err
tryRun (errnum + 1) oknum as
Right _ -> tryRun errnum (oknum + 1) as
{- Exception pretty-printing. -}
showErr :: SomeException -> IO ()
showErr e = do
let err = show e
hPutStrLn stderr $ "git-annex: " ++ err
return ()
|