Fixed a bug in which the --no-clear flag was not respected

This commit is contained in:
Tom Sydney Kerckhove 2022-03-06 12:12:09 +01:00
parent e25bf7aea4
commit 343ab6a5a8
3 changed files with 13 additions and 11 deletions

View File

@ -32,8 +32,6 @@ library
, autodocodec-yaml
, base >=4.7 && <5
, bytestring
, conduit
, conduit-extra
, containers
, cursor
, envparse
@ -42,6 +40,7 @@ library
, optparse-applicative
, path
, path-io
, pretty-show
, process
, safe-coloured-text
, safe-coloured-text-terminfo

View File

@ -16,9 +16,6 @@ library:
- autodocodec
- autodocodec-yaml
- bytestring
- conduit
- conduit-extra
- containers
- containers
- cursor
- envparse
@ -27,6 +24,7 @@ library:
- optparse-applicative
- path
- path-io
- pretty-show
- process
- safe-coloured-text
- safe-coloured-text-terminfo

View File

@ -23,6 +23,7 @@ import Options.Applicative as OptParse
import qualified Options.Applicative.Help as OptParse (string)
import Path
import Path.IO
import Text.Show.Pretty (pPrint)
getSettings :: IO Settings
getSettings = do
@ -64,12 +65,14 @@ combineToSettings Flags {..} Environment {} mConf = do
"as the name of a configured loop"
]
pure loopConfigCommand
let settingOutputSettings = combineToOutputSettings (mConf >>= configOutputConfiguration)
pure Settings {..}
let settingOutputSettings = combineToOutputSettings flagOutputFlags (mConf >>= configOutputConfiguration)
let settings = Settings {..}
when flagDebug $ pPrint settings
pure settings
combineToOutputSettings :: Maybe OutputConfiguration -> OutputSettings
combineToOutputSettings mConf =
let outputSettingClear = fromMaybe ClearScreen $ mConf >>= outputConfigClear
combineToOutputSettings :: OutputFlags -> Maybe OutputConfiguration -> OutputSettings
combineToOutputSettings OutputFlags {..} mConf =
let outputSettingClear = fromMaybe ClearScreen $ outputFlagClear <|> (mConf >>= outputConfigClear)
in OutputSettings {..}
data Configuration = Configuration
@ -166,7 +169,8 @@ flagsParser =
data Flags = Flags
{ flagConfigFile :: !(Maybe FilePath),
flagCommand :: !String,
flagOutputFlags :: !OutputFlags
flagOutputFlags :: !OutputFlags,
flagDebug :: Bool
}
deriving (Show, Eq, Generic)
@ -197,6 +201,7 @@ parseFlags =
)
)
<*> parseOutputFlags
<*> switch (mconcat [long "debug", help "show debug information"])
parseOutputFlags :: OptParse.Parser OutputFlags
parseOutputFlags =