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 -> 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 (parsers, cmds, []) -> do
25 foldl (\acc parser -> acc >>= parser context) (return ctx) parsers
28 usage >>= Write.fatal context . (concat errs ++)