1 {-# LANGUAGE NamedFieldPuns #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 module Hcompta.CLI.Context where
5 import Control.Monad (liftM)
6 import qualified Data.List
7 import Data.Maybe (catMaybes)
8 import qualified Data.Text as Text
9 import Data.Text (Text)
10 import System.Environment (getEnvironment)
11 import System.IO.Memoize (once)
17 { verbosity :: Verbosity
28 { verbosity = Verbosity_Info
39 deriving (Bounded, Enum, Eq, Ord, Show)
41 -- TODO: check that this is expected behavior
42 -- and portability issues
43 get_langs :: IO [Text]
50 let short = takeWhile ('_' /=) lang in
54 . Data.List.takeWhile (\c -> c /= '.') ) $
56 [ Data.List.lookup "LC_ALL" env
57 , Data.List.lookup "LC_CTYPE" env
58 , Data.List.lookup "LANG" env