module Argo.Internal.Type.Settings where import qualified Argo.Internal.Type.Flag as Flag import qualified Argo.Internal.Type.Indent as Indent import qualified Text.Read as Read data Settings = Settings { Settings -> Bool help :: Bool , Settings -> Indent indent :: Indent.Indent , Settings -> Bool version :: Bool } deriving (Settings -> Settings -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Settings -> Settings -> Bool $c/= :: Settings -> Settings -> Bool == :: Settings -> Settings -> Bool $c== :: Settings -> Settings -> Bool Eq, Int -> Settings -> ShowS [Settings] -> ShowS Settings -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Settings] -> ShowS $cshowList :: [Settings] -> ShowS show :: Settings -> String $cshow :: Settings -> String showsPrec :: Int -> Settings -> ShowS $cshowsPrec :: Int -> Settings -> ShowS Show) initial :: Settings initial :: Settings initial = Settings { help :: Bool help = Bool False, indent :: Indent indent = Int -> Indent Indent.Spaces Int 0, version :: Bool version = Bool False } applyFlag :: Settings -> Flag.Flag -> Either String Settings applyFlag :: Settings -> Flag -> Either String Settings applyFlag Settings settings Flag flag = case Flag flag of Flag Flag.Help -> forall (f :: * -> *) a. Applicative f => a -> f a pure Settings settings { help :: Bool help = Bool True } Flag.Spaces String string -> do Int int <- forall a. Read a => String -> Either String a Read.readEither String string forall (f :: * -> *) a. Applicative f => a -> f a pure Settings settings { indent :: Indent indent = Int -> Indent Indent.Spaces Int int } Flag Flag.Tab -> forall (f :: * -> *) a. Applicative f => a -> f a pure Settings settings { indent :: Indent indent = Indent Indent.Tab } Flag Flag.Version -> forall (f :: * -> *) a. Applicative f => a -> f a pure Settings settings { version :: Bool version = Bool True }