module Shrun.Configuration.Args.Parsing.CommonLogging
( commonLoggingParser,
)
where
import Options.Applicative (Parser)
import Shrun.Configuration.Args.Parsing.Utils qualified as Utils
import Shrun.Configuration.Data.CommonLogging
( CommonLoggingArgs,
CommonLoggingP (MkCommonLoggingP),
Debug (MkDebug),
)
import Shrun.Configuration.Data.CommonLogging.KeyHideSwitch
( KeyHideSwitch (MkKeyHideSwitch),
)
import Shrun.Prelude
commonLoggingParser :: Parser CommonLoggingArgs
commonLoggingParser :: Parser CommonLoggingArgs
commonLoggingParser = Maybe Debug -> Maybe KeyHideSwitch -> CommonLoggingArgs
SwitchF 'ConfigPhaseArgs Debug
-> SwitchF 'ConfigPhaseArgs KeyHideSwitch -> CommonLoggingArgs
forall (p :: ConfigPhase).
SwitchF p Debug -> SwitchF p KeyHideSwitch -> CommonLoggingP p
MkCommonLoggingP (Maybe Debug -> Maybe KeyHideSwitch -> CommonLoggingArgs)
-> Parser (Maybe Debug)
-> Parser (Maybe KeyHideSwitch -> CommonLoggingArgs)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (Maybe Debug)
debugParser Parser (Maybe KeyHideSwitch -> CommonLoggingArgs)
-> Parser (Maybe KeyHideSwitch) -> Parser CommonLoggingArgs
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Parser (Maybe KeyHideSwitch)
keyHideParser
debugParser :: Parser (Maybe Debug)
debugParser :: Parser (Maybe Debug)
debugParser = (Bool -> Debug) -> String -> String -> Parser (Maybe Debug)
forall a. (Bool -> a) -> String -> String -> Parser (Maybe a)
Utils.switchParser Bool -> Debug
MkDebug String
"common-log-debug" String
helpTxt
where
helpTxt :: String
helpTxt = String
"Enables additional debug logging."
keyHideParser :: Parser (Maybe KeyHideSwitch)
keyHideParser :: Parser (Maybe KeyHideSwitch)
keyHideParser = (Bool -> KeyHideSwitch)
-> String -> String -> Parser (Maybe KeyHideSwitch)
forall a. (Bool -> a) -> String -> String -> Parser (Maybe a)
Utils.switchParserNoLine Bool -> KeyHideSwitch
MkKeyHideSwitch String
"common-log-key-hide" String
helpTxt
where
helpTxt :: String
helpTxt =
[String] -> String
forall a. Monoid a => [a] -> a
mconcat
[ String
"By default, we display the key name from the legend over the ",
String
"actual command that was run, if the former exists. This flag ",
String
"instead shows the literal command. Commands without keys are ",
String
"unaffected."
]