module Shell.Utility.Verbosity (
Verbosity,
silent, normal, verbose, deafening,
parse,
) where
import qualified Shell.Utility.Exit as Exit
import Control.Applicative (pure)
data Verbosity = Silent | Normal | Verbose | Deafening
deriving (Show, Read, Eq, Ord, Enum, Bounded)
silent :: Verbosity
silent = Silent
normal :: Verbosity
normal = Normal
verbose :: Verbosity
verbose = Verbose
deafening :: Verbosity
deafening = Deafening
parse :: (Exit.Exit m) => String -> m Verbosity
parse "" = Exit.exitFailureMsg "empty verbosity identifier"
parse [c] =
case c of
'0' -> pure Silent
'1' -> pure Normal
'2' -> pure Verbose
'3' -> pure Deafening
_ -> Exit.exitFailureMsg "verbosity must be a number from [0..3]"
parse _ = Exit.exitFailureMsg "more than one character for verbosity"