1 {-# LANGUAGE TupleSections #-}
2 module Hcompta.CLI.Args where
4 import System.Console.GetOpt
10 import Hcompta.CLI.Context (Context)
11 import qualified Hcompta.CLI.Write as Write
14 = [OptDescr (context -> IO context)]
20 -> (context, [String])
21 -> IO (context, [String])
22 parse context usage options (ctx, args) =
23 case getOpt RequireOrder options args of
24 (ctx_, cmds, []) -> do
25 foldl (>>=) (return ctx) ctx_
28 usage >>= Write.fatal context . (concat errs ++)