]> Git — Sourcephile - comptalang.git/blob - cli/Hcompta/CLI/Main.hs
Improve section checking and warn when a term is redefined.
[comptalang.git] / cli / Hcompta / CLI / Main.hs
1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE TupleSections #-}
3 module Main (main) where
4
5 import Control.Monad (Monad(..))
6 import Data.Function ((.))
7 import Data.Monoid ((<>))
8 import qualified Data.Text.Lazy as TL
9 import qualified System.Environment as Env
10 import System.IO (IO)
11 import qualified Text.WalderLeijen.ANSI.Text as W
12
13 import qualified Hcompta.CLI.Args as Args
14 import qualified Hcompta.CLI.Command as Command
15 import qualified Hcompta.CLI.Context as C
16 import qualified Hcompta.CLI.Lang as Lang
17 import qualified Hcompta.CLI.Write as Write
18
19 main :: IO ()
20 main = do
21 (c, cmds) <- do
22 c <- C.context
23 Env.getArgs >>= Args.parse c Command.usage Command.options . (c,)
24 case cmds of
25 cmd:args -> Command.run c cmd args
26 [] -> Command.usage c
27 >>= Write.fatal c .
28 ((C.translate c Lang.Error_One_command_is_required <> W.line) <>) .
29 W.text . TL.pack