]> Git — Sourcephile - comptalang.git/blob - cli/Hcompta/CLI/Context.hs
Sync with symantic.
[comptalang.git] / cli / Hcompta / CLI / Context.hs
1 {-# LANGUAGE FlexibleInstances #-}
2 {-# LANGUAGE NamedFieldPuns #-}
3 {-# LANGUAGE OverloadedStrings #-}
4 module Hcompta.CLI.Context where
5
6 import Control.Monad (Monad(..))
7 import Data.Bool
8 import Data.String (String)
9 import Data.Eq (Eq)
10 import Data.Maybe (Maybe(..))
11 import Data.Ord (Ord)
12 import Text.Show (Show)
13 import Prelude (($), (.), Bounded(..), Enum(..), IO)
14
15 import Hcompta.CLI.Lang (Lang)
16 import qualified Hcompta.CLI.Lang as Lang
17
18 data App = App
19
20 data Context
21 = Context
22 { verbosity :: Verbosity
23 , command :: String
24 , color :: Maybe Bool
25 , lang :: Lang
26 } deriving (Show)
27
28 context :: IO Context
29 context = do
30 lang <- Lang.from_Env
31 return $
32 Context
33 { verbosity = Verbosity_Info
34 , command = ""
35 , color = Nothing
36 , lang
37 }
38
39 data Verbosity
40 = Verbosity_Error
41 | Verbosity_Warn
42 | Verbosity_Info
43 | Verbosity_Debug
44 deriving (Bounded, Eq, Enum, Ord, Show)
45
46 translate :: Lang.Translate f t => Context -> f -> t
47 translate = Lang.translate . lang