{-# LANGUAGE UndecidableInstances #-}

module Shrun.Configuration.Data.ConsoleLogging
  ( -- * Types
    ConsoleLoggingP (..),
    ConsoleLoggingArgs,
    ConsoleLoggingToml,
    ConsoleLoggingMerged,
    ConsoleLoggingEnv,
    ConsoleLogCmdSwitch (..),

    -- * Functions
    mergeConsoleLogging,
    toEnv,
  )
where

import Shrun.Configuration.Data.ConfigPhase
  ( ConfigPhase
      ( ConfigPhaseArgs,
        ConfigPhaseEnv,
        ConfigPhaseMerged,
        ConfigPhaseToml
      ),
    ConfigPhaseDisabledMaybeF,
    ConfigPhaseF,
    LineTruncF,
    SwitchF,
    parseSwitch,
  )
import Shrun.Configuration.Data.ConsoleLogging.TimerFormat (TimerFormat)
import Shrun.Configuration.Data.StripControl (ConsoleLogStripControl)
import Shrun.Configuration.Data.Truncation
  ( DetectResult,
    TruncRegion (TruncCommandName),
    Truncation,
    decodeCommandNameTrunc,
    decodeLineTrunc,
    mergeLineTrunc,
  )
import Shrun.Configuration.Data.WithDisabled ((<|?|>))
import Shrun.Configuration.Default (Default (def), (<.>))
import Shrun.Prelude

-- | Switch for command logging in console logs.
newtype ConsoleLogCmdSwitch = MkConsoleLogCmdSwitch Bool
  deriving stock (ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> Bool
(ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> Bool)
-> (ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> Bool)
-> Eq ConsoleLogCmdSwitch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> Bool
== :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> Bool
$c/= :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> Bool
/= :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> Bool
Eq, Int -> ConsoleLogCmdSwitch -> ShowS
[ConsoleLogCmdSwitch] -> ShowS
ConsoleLogCmdSwitch -> String
(Int -> ConsoleLogCmdSwitch -> ShowS)
-> (ConsoleLogCmdSwitch -> String)
-> ([ConsoleLogCmdSwitch] -> ShowS)
-> Show ConsoleLogCmdSwitch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConsoleLogCmdSwitch -> ShowS
showsPrec :: Int -> ConsoleLogCmdSwitch -> ShowS
$cshow :: ConsoleLogCmdSwitch -> String
show :: ConsoleLogCmdSwitch -> String
$cshowList :: [ConsoleLogCmdSwitch] -> ShowS
showList :: [ConsoleLogCmdSwitch] -> ShowS
Show)
  deriving newtype (ConsoleLogCmdSwitch
ConsoleLogCmdSwitch
-> ConsoleLogCmdSwitch -> Bounded ConsoleLogCmdSwitch
forall a. a -> a -> Bounded a
$cminBound :: ConsoleLogCmdSwitch
minBound :: ConsoleLogCmdSwitch
$cmaxBound :: ConsoleLogCmdSwitch
maxBound :: ConsoleLogCmdSwitch
Bounded, Int -> ConsoleLogCmdSwitch
ConsoleLogCmdSwitch -> Int
ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch]
ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch
ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch]
ConsoleLogCmdSwitch
-> ConsoleLogCmdSwitch
-> ConsoleLogCmdSwitch
-> [ConsoleLogCmdSwitch]
(ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch)
-> (ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch)
-> (Int -> ConsoleLogCmdSwitch)
-> (ConsoleLogCmdSwitch -> Int)
-> (ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch])
-> (ConsoleLogCmdSwitch
    -> ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch])
-> (ConsoleLogCmdSwitch
    -> ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch])
-> (ConsoleLogCmdSwitch
    -> ConsoleLogCmdSwitch
    -> ConsoleLogCmdSwitch
    -> [ConsoleLogCmdSwitch])
-> Enum ConsoleLogCmdSwitch
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch
succ :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch
$cpred :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch
pred :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch
$ctoEnum :: Int -> ConsoleLogCmdSwitch
toEnum :: Int -> ConsoleLogCmdSwitch
$cfromEnum :: ConsoleLogCmdSwitch -> Int
fromEnum :: ConsoleLogCmdSwitch -> Int
$cenumFrom :: ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch]
enumFrom :: ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch]
$cenumFromThen :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch]
enumFromThen :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch]
$cenumFromTo :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch]
enumFromTo :: ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch -> [ConsoleLogCmdSwitch]
$cenumFromThenTo :: ConsoleLogCmdSwitch
-> ConsoleLogCmdSwitch
-> ConsoleLogCmdSwitch
-> [ConsoleLogCmdSwitch]
enumFromThenTo :: ConsoleLogCmdSwitch
-> ConsoleLogCmdSwitch
-> ConsoleLogCmdSwitch
-> [ConsoleLogCmdSwitch]
Enum)
  deriving ((forall ann. ConsoleLogCmdSwitch -> Doc ann)
-> (forall ann. [ConsoleLogCmdSwitch] -> Doc ann)
-> Pretty ConsoleLogCmdSwitch
forall ann. [ConsoleLogCmdSwitch] -> Doc ann
forall ann. ConsoleLogCmdSwitch -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. ConsoleLogCmdSwitch -> Doc ann
pretty :: forall ann. ConsoleLogCmdSwitch -> Doc ann
$cprettyList :: forall ann. [ConsoleLogCmdSwitch] -> Doc ann
prettyList :: forall ann. [ConsoleLogCmdSwitch] -> Doc ann
Pretty) via PrettySwitch

instance Default ConsoleLogCmdSwitch where
  def :: ConsoleLogCmdSwitch
def = Bool -> ConsoleLogCmdSwitch
MkConsoleLogCmdSwitch Bool
True

instance DecodeTOML ConsoleLogCmdSwitch where
  tomlDecoder :: Decoder ConsoleLogCmdSwitch
tomlDecoder = Bool -> ConsoleLogCmdSwitch
MkConsoleLogCmdSwitch (Bool -> ConsoleLogCmdSwitch)
-> Decoder Bool -> Decoder ConsoleLogCmdSwitch
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (Decoder Text
forall a. DecodeTOML a => Decoder a
tomlDecoder Decoder Text -> (Text -> Decoder Bool) -> Decoder Bool
forall a b. Decoder a -> (a -> Decoder b) -> Decoder b
forall (m :: Type -> Type) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Decoder Bool
forall (m :: Type -> Type). MonadFail m => Text -> m Bool
parseSwitch)

instance
  (k ~ An_Iso, a ~ Bool, b ~ Bool) =>
  LabelOptic
    "unConsoleLogCmdSwitch"
    k
    ConsoleLogCmdSwitch
    ConsoleLogCmdSwitch
    a
    b
  where
  labelOptic :: Optic k NoIx ConsoleLogCmdSwitch ConsoleLogCmdSwitch a b
labelOptic = (ConsoleLogCmdSwitch -> a)
-> (b -> ConsoleLogCmdSwitch)
-> Iso ConsoleLogCmdSwitch ConsoleLogCmdSwitch a b
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (\(MkConsoleLogCmdSwitch Bool
b) -> a
Bool
b) b -> ConsoleLogCmdSwitch
Bool -> ConsoleLogCmdSwitch
MkConsoleLogCmdSwitch

-- | Holds command logging config.
type ConsoleLoggingP :: ConfigPhase -> Type
data ConsoleLoggingP p = MkConsoleLoggingP
  { -- | Whether command logging is With.
    forall (p :: ConfigPhase).
ConsoleLoggingP p -> SwitchF p ConsoleLogCmdSwitch
commandLogging :: SwitchF p ConsoleLogCmdSwitch,
    -- | Command name truncation.
    forall (p :: ConfigPhase).
ConsoleLoggingP p
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
commandNameTrunc :: ConfigPhaseDisabledMaybeF p (Truncation TruncCommandName),
    -- | Line truncation.
    forall (p :: ConfigPhase). ConsoleLoggingP p -> LineTruncF p
lineTrunc :: LineTruncF p,
    -- | Strip control.
    forall (p :: ConfigPhase).
ConsoleLoggingP p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
stripControl :: ConfigPhaseF p ConsoleLogStripControl,
    -- | How to format the timer.
    forall (p :: ConfigPhase).
ConsoleLoggingP p -> ConfigPhaseF p TimerFormat
timerFormat :: ConfigPhaseF p TimerFormat
  }

instance
  ( k ~ A_Lens,
    a ~ SwitchF p ConsoleLogCmdSwitch,
    b ~ SwitchF p ConsoleLogCmdSwitch
  ) =>
  LabelOptic "commandLogging" k (ConsoleLoggingP p) (ConsoleLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (ConsoleLoggingP p) (ConsoleLoggingP p) a b
labelOptic =
    LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
 -> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b)
-> LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkConsoleLoggingP SwitchF p ConsoleLogCmdSwitch
a1 ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2 LineTruncF p
a3 ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4 ConfigPhaseF p TimerFormat
a5) ->
        (b -> ConsoleLoggingP p) -> f b -> f (ConsoleLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
forall (p :: ConfigPhase).
SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
MkConsoleLoggingP b
SwitchF p ConsoleLogCmdSwitch
b ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2 LineTruncF p
a3 ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4 ConfigPhaseF p TimerFormat
a5)
          (a -> f b
f a
SwitchF p ConsoleLogCmdSwitch
a1)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ ConfigPhaseDisabledMaybeF p (Truncation TruncCommandName),
    b ~ ConfigPhaseDisabledMaybeF p (Truncation TruncCommandName)
  ) =>
  LabelOptic "commandNameTrunc" k (ConsoleLoggingP p) (ConsoleLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (ConsoleLoggingP p) (ConsoleLoggingP p) a b
labelOptic =
    LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
 -> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b)
-> LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkConsoleLoggingP SwitchF p ConsoleLogCmdSwitch
a1 ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2 LineTruncF p
a3 ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4 ConfigPhaseF p TimerFormat
a5) ->
        (b -> ConsoleLoggingP p) -> f b -> f (ConsoleLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
forall (p :: ConfigPhase).
SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
MkConsoleLoggingP SwitchF p ConsoleLogCmdSwitch
a1 b
ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
b LineTruncF p
a3 ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4 ConfigPhaseF p TimerFormat
a5)
          (a -> f b
f a
ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ LineTruncF p,
    b ~ LineTruncF p
  ) =>
  LabelOptic "lineTrunc" k (ConsoleLoggingP p) (ConsoleLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (ConsoleLoggingP p) (ConsoleLoggingP p) a b
labelOptic =
    LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
 -> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b)
-> LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkConsoleLoggingP SwitchF p ConsoleLogCmdSwitch
a1 ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2 LineTruncF p
a3 ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4 ConfigPhaseF p TimerFormat
a5) ->
        (b -> ConsoleLoggingP p) -> f b -> f (ConsoleLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
forall (p :: ConfigPhase).
SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
MkConsoleLoggingP SwitchF p ConsoleLogCmdSwitch
a1 ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2 b
LineTruncF p
b ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4 ConfigPhaseF p TimerFormat
a5)
          (a -> f b
f a
LineTruncF p
a3)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ ConfigPhaseF p ConsoleLogStripControl,
    b ~ ConfigPhaseF p ConsoleLogStripControl
  ) =>
  LabelOptic "stripControl" k (ConsoleLoggingP p) (ConsoleLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (ConsoleLoggingP p) (ConsoleLoggingP p) a b
labelOptic =
    LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
 -> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b)
-> LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkConsoleLoggingP SwitchF p ConsoleLogCmdSwitch
a1 ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2 LineTruncF p
a3 ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4 ConfigPhaseF p TimerFormat
a5) ->
        (b -> ConsoleLoggingP p) -> f b -> f (ConsoleLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
forall (p :: ConfigPhase).
SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
MkConsoleLoggingP SwitchF p ConsoleLogCmdSwitch
a1 ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2 LineTruncF p
a3 b
ConfigPhaseF p (StripControl 'StripControlConsoleLog)
b ConfigPhaseF p TimerFormat
a5)
          (a -> f b
f a
ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4)
  {-# INLINE labelOptic #-}

instance
  ( k ~ A_Lens,
    a ~ ConfigPhaseF p TimerFormat,
    b ~ ConfigPhaseF p TimerFormat
  ) =>
  LabelOptic "timerFormat" k (ConsoleLoggingP p) (ConsoleLoggingP p) a b
  where
  labelOptic :: Optic k NoIx (ConsoleLoggingP p) (ConsoleLoggingP p) a b
labelOptic =
    LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL
      (LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
 -> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b)
-> LensVL (ConsoleLoggingP p) (ConsoleLoggingP p) a b
-> Lens (ConsoleLoggingP p) (ConsoleLoggingP p) a b
forall a b. (a -> b) -> a -> b
$ \a -> f b
f (MkConsoleLoggingP SwitchF p ConsoleLogCmdSwitch
a1 ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2 LineTruncF p
a3 ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4 ConfigPhaseF p TimerFormat
a5) ->
        (b -> ConsoleLoggingP p) -> f b -> f (ConsoleLoggingP p)
forall a b. (a -> b) -> f a -> f b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap
          (\b
b -> SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
forall (p :: ConfigPhase).
SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
MkConsoleLoggingP SwitchF p ConsoleLogCmdSwitch
a1 ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
a2 LineTruncF p
a3 ConfigPhaseF p (StripControl 'StripControlConsoleLog)
a4 b
ConfigPhaseF p TimerFormat
b)
          (a -> f b
f a
ConfigPhaseF p TimerFormat
a5)
  {-# INLINE labelOptic #-}

instance Semigroup ConsoleLoggingToml where
  ConsoleLoggingToml
l <> :: ConsoleLoggingToml -> ConsoleLoggingToml -> ConsoleLoggingToml
<> ConsoleLoggingToml
r =
    MkConsoleLoggingP
      { commandLogging :: SwitchF 'ConfigPhaseToml ConsoleLogCmdSwitch
commandLogging = ConsoleLoggingToml
l ConsoleLoggingToml
-> Optic'
     A_Lens NoIx ConsoleLoggingToml (Maybe ConsoleLogCmdSwitch)
-> Maybe ConsoleLogCmdSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingToml (Maybe ConsoleLogCmdSwitch)
#commandLogging Maybe ConsoleLogCmdSwitch
-> Maybe ConsoleLogCmdSwitch -> Maybe ConsoleLogCmdSwitch
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> ConsoleLoggingToml
r ConsoleLoggingToml
-> Optic'
     A_Lens NoIx ConsoleLoggingToml (Maybe ConsoleLogCmdSwitch)
-> Maybe ConsoleLogCmdSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingToml (Maybe ConsoleLogCmdSwitch)
#commandLogging,
        commandNameTrunc :: ConfigPhaseDisabledMaybeF
  'ConfigPhaseToml (Truncation 'TruncCommandName)
commandNameTrunc = ConsoleLoggingToml
l ConsoleLoggingToml
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingToml
     (Maybe (WithDisabled (Truncation 'TruncCommandName)))
-> Maybe (WithDisabled (Truncation 'TruncCommandName))
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingToml
  (Maybe (WithDisabled (Truncation 'TruncCommandName)))
#commandNameTrunc Maybe (WithDisabled (Truncation 'TruncCommandName))
-> Maybe (WithDisabled (Truncation 'TruncCommandName))
-> Maybe (WithDisabled (Truncation 'TruncCommandName))
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> ConsoleLoggingToml
r ConsoleLoggingToml
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingToml
     (Maybe (WithDisabled (Truncation 'TruncCommandName)))
-> Maybe (WithDisabled (Truncation 'TruncCommandName))
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingToml
  (Maybe (WithDisabled (Truncation 'TruncCommandName)))
#commandNameTrunc,
        lineTrunc :: LineTruncF 'ConfigPhaseToml
lineTrunc = ConsoleLoggingToml
l ConsoleLoggingToml
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingToml
     (Maybe (WithDisabled LineTruncation))
-> Maybe (WithDisabled LineTruncation)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingToml
  (Maybe (WithDisabled LineTruncation))
#lineTrunc Maybe (WithDisabled LineTruncation)
-> Maybe (WithDisabled LineTruncation)
-> Maybe (WithDisabled LineTruncation)
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> ConsoleLoggingToml
r ConsoleLoggingToml
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingToml
     (Maybe (WithDisabled LineTruncation))
-> Maybe (WithDisabled LineTruncation)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingToml
  (Maybe (WithDisabled LineTruncation))
#lineTrunc,
        stripControl :: ConfigPhaseF
  'ConfigPhaseToml (StripControl 'StripControlConsoleLog)
stripControl = ConsoleLoggingToml
l ConsoleLoggingToml
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingToml
     (Maybe (StripControl 'StripControlConsoleLog))
-> Maybe (StripControl 'StripControlConsoleLog)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingToml
  (Maybe (StripControl 'StripControlConsoleLog))
#stripControl Maybe (StripControl 'StripControlConsoleLog)
-> Maybe (StripControl 'StripControlConsoleLog)
-> Maybe (StripControl 'StripControlConsoleLog)
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> ConsoleLoggingToml
r ConsoleLoggingToml
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingToml
     (Maybe (StripControl 'StripControlConsoleLog))
-> Maybe (StripControl 'StripControlConsoleLog)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingToml
  (Maybe (StripControl 'StripControlConsoleLog))
#stripControl,
        timerFormat :: ConfigPhaseF 'ConfigPhaseToml TimerFormat
timerFormat = ConsoleLoggingToml
l ConsoleLoggingToml
-> Optic' A_Lens NoIx ConsoleLoggingToml (Maybe TimerFormat)
-> Maybe TimerFormat
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingToml (Maybe TimerFormat)
#timerFormat Maybe TimerFormat -> Maybe TimerFormat -> Maybe TimerFormat
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> ConsoleLoggingToml
r ConsoleLoggingToml
-> Optic' A_Lens NoIx ConsoleLoggingToml (Maybe TimerFormat)
-> Maybe TimerFormat
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingToml (Maybe TimerFormat)
#timerFormat
      }

instance Monoid ConsoleLoggingToml where
  mempty :: ConsoleLoggingToml
mempty =
    MkConsoleLoggingP
      { commandLogging :: SwitchF 'ConfigPhaseToml ConsoleLogCmdSwitch
commandLogging = Maybe ConsoleLogCmdSwitch
SwitchF 'ConfigPhaseToml ConsoleLogCmdSwitch
forall a. Maybe a
Nothing,
        commandNameTrunc :: ConfigPhaseDisabledMaybeF
  'ConfigPhaseToml (Truncation 'TruncCommandName)
commandNameTrunc = Maybe (WithDisabled (Truncation 'TruncCommandName))
ConfigPhaseDisabledMaybeF
  'ConfigPhaseToml (Truncation 'TruncCommandName)
forall a. Maybe a
Nothing,
        lineTrunc :: LineTruncF 'ConfigPhaseToml
lineTrunc = Maybe (WithDisabled LineTruncation)
LineTruncF 'ConfigPhaseToml
forall a. Maybe a
Nothing,
        stripControl :: ConfigPhaseF
  'ConfigPhaseToml (StripControl 'StripControlConsoleLog)
stripControl = Maybe (StripControl 'StripControlConsoleLog)
ConfigPhaseF
  'ConfigPhaseToml (StripControl 'StripControlConsoleLog)
forall a. Maybe a
Nothing,
        timerFormat :: ConfigPhaseF 'ConfigPhaseToml TimerFormat
timerFormat = Maybe TimerFormat
ConfigPhaseF 'ConfigPhaseToml TimerFormat
forall a. Maybe a
Nothing
      }

instance Pretty ConsoleLoggingMerged where
  pretty :: forall ann. ConsoleLoggingMerged -> Doc ann
pretty ConsoleLoggingMerged
c =
    [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vcat
      [ Doc ann
"command-logging: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> ConsoleLogCmdSwitch -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ConsoleLogCmdSwitch -> Doc ann
pretty (ConsoleLoggingMerged
c ConsoleLoggingMerged
-> Optic' A_Lens NoIx ConsoleLoggingMerged ConsoleLogCmdSwitch
-> ConsoleLogCmdSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingMerged ConsoleLogCmdSwitch
#commandLogging),
        Doc ann
"command-name-trunc: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Maybe (Truncation 'TruncCommandName) -> Doc ann
forall a ann. Pretty a => Maybe a -> Doc ann
prettyMaybe (ConsoleLoggingMerged
c ConsoleLoggingMerged
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingMerged
     (Maybe (Truncation 'TruncCommandName))
-> Maybe (Truncation 'TruncCommandName)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingMerged
  (Maybe (Truncation 'TruncCommandName))
#commandNameTrunc),
        Doc ann
"line-trunc: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Maybe (Truncation 'TruncLine) -> Doc ann
forall a ann. Pretty a => Maybe a -> Doc ann
prettyMaybe (ConsoleLoggingMerged
c ConsoleLoggingMerged
-> Optic'
     A_Lens NoIx ConsoleLoggingMerged (Maybe (Truncation 'TruncLine))
-> Maybe (Truncation 'TruncLine)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx ConsoleLoggingMerged (Maybe (Truncation 'TruncLine))
#lineTrunc),
        Doc ann
"strip-control: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> StripControl 'StripControlConsoleLog -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. StripControl 'StripControlConsoleLog -> Doc ann
pretty (ConsoleLoggingMerged
c ConsoleLoggingMerged
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingMerged
     (StripControl 'StripControlConsoleLog)
-> StripControl 'StripControlConsoleLog
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingMerged
  (StripControl 'StripControlConsoleLog)
#stripControl),
        Doc ann
"timer-format: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> TimerFormat -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. TimerFormat -> Doc ann
pretty (ConsoleLoggingMerged
c ConsoleLoggingMerged
-> Optic' A_Lens NoIx ConsoleLoggingMerged TimerFormat
-> TimerFormat
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingMerged TimerFormat
#timerFormat)
      ]

type ConsoleLoggingArgs = ConsoleLoggingP ConfigPhaseArgs

type ConsoleLoggingToml = ConsoleLoggingP ConfigPhaseToml

type ConsoleLoggingMerged = ConsoleLoggingP ConfigPhaseMerged

type ConsoleLoggingEnv = ConsoleLoggingP ConfigPhaseEnv

deriving stock instance Eq (ConsoleLoggingP ConfigPhaseArgs)

deriving stock instance Show (ConsoleLoggingP ConfigPhaseArgs)

deriving stock instance Eq (ConsoleLoggingP ConfigPhaseToml)

deriving stock instance Show (ConsoleLoggingP ConfigPhaseToml)

deriving stock instance Eq (ConsoleLoggingP ConfigPhaseMerged)

deriving stock instance Show (ConsoleLoggingP ConfigPhaseMerged)

instance Default ConsoleLoggingArgs where
  def :: ConsoleLoggingP 'ConfigPhaseArgs
def =
    MkConsoleLoggingP
      { commandLogging :: SwitchF 'ConfigPhaseArgs ConsoleLogCmdSwitch
commandLogging = Maybe ConsoleLogCmdSwitch
SwitchF 'ConfigPhaseArgs ConsoleLogCmdSwitch
forall a. Maybe a
Nothing,
        commandNameTrunc :: ConfigPhaseDisabledMaybeF
  'ConfigPhaseArgs (Truncation 'TruncCommandName)
commandNameTrunc = Maybe (WithDisabled (Truncation 'TruncCommandName))
ConfigPhaseDisabledMaybeF
  'ConfigPhaseArgs (Truncation 'TruncCommandName)
forall a. Maybe a
Nothing,
        lineTrunc :: LineTruncF 'ConfigPhaseArgs
lineTrunc = Maybe (WithDisabled LineTruncation)
LineTruncF 'ConfigPhaseArgs
forall a. Maybe a
Nothing,
        stripControl :: ConfigPhaseF
  'ConfigPhaseArgs (StripControl 'StripControlConsoleLog)
stripControl = Maybe (StripControl 'StripControlConsoleLog)
ConfigPhaseF
  'ConfigPhaseArgs (StripControl 'StripControlConsoleLog)
forall a. Maybe a
Nothing,
        timerFormat :: ConfigPhaseF 'ConfigPhaseArgs TimerFormat
timerFormat = Maybe TimerFormat
ConfigPhaseF 'ConfigPhaseArgs TimerFormat
forall a. Maybe a
Nothing
      }

-- | Merges args and toml configs.
mergeConsoleLogging ::
  ( HasCallStack,
    MonadCatch m,
    MonadIORef m,
    MonadTerminal m
  ) =>
  IORef DetectResult ->
  ConsoleLoggingArgs ->
  Maybe ConsoleLoggingToml ->
  m ConsoleLoggingMerged
mergeConsoleLogging :: forall (m :: Type -> Type).
(HasCallStack, MonadCatch m, MonadIORef m, MonadTerminal m) =>
IORef DetectResult
-> ConsoleLoggingP 'ConfigPhaseArgs
-> Maybe ConsoleLoggingToml
-> m ConsoleLoggingMerged
mergeConsoleLogging IORef DetectResult
detectRef ConsoleLoggingP 'ConfigPhaseArgs
args Maybe ConsoleLoggingToml
mToml = do
  let commandLogging :: ConsoleLogCmdSwitch
commandLogging =
        ConsoleLoggingP 'ConfigPhaseArgs
args
          ConsoleLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (ConsoleLoggingP 'ConfigPhaseArgs)
     (Maybe ConsoleLogCmdSwitch)
-> Maybe ConsoleLogCmdSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (ConsoleLoggingP 'ConfigPhaseArgs)
  (Maybe ConsoleLogCmdSwitch)
#commandLogging
          Maybe ConsoleLogCmdSwitch
-> Maybe ConsoleLogCmdSwitch -> ConsoleLogCmdSwitch
forall a. Default a => Maybe a -> Maybe a -> a
<.> ConsoleLoggingToml
toml
          ConsoleLoggingToml
-> Optic'
     A_Lens NoIx ConsoleLoggingToml (Maybe ConsoleLogCmdSwitch)
-> Maybe ConsoleLogCmdSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingToml (Maybe ConsoleLogCmdSwitch)
#commandLogging
      -- Default to 'detect' iff command logging is on. We do this because the
      -- only logs likely to need line truncation are long command  logs.
      defDetect :: Bool
defDetect = ConsoleLogCmdSwitch
commandLogging ConsoleLogCmdSwitch
-> Optic' An_Iso NoIx ConsoleLogCmdSwitch Bool -> Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' An_Iso NoIx ConsoleLogCmdSwitch Bool
#unConsoleLogCmdSwitch

  Maybe (Truncation 'TruncLine)
lineTrunc <-
    Bool
-> IORef DetectResult
-> Maybe (WithDisabled LineTruncation)
-> Maybe (WithDisabled LineTruncation)
-> m (Maybe (Truncation 'TruncLine))
forall (m :: Type -> Type).
(HasCallStack, MonadCatch m, MonadIORef m, MonadTerminal m) =>
Bool
-> IORef DetectResult
-> Maybe (WithDisabled LineTruncation)
-> Maybe (WithDisabled LineTruncation)
-> m (Maybe (Truncation 'TruncLine))
mergeLineTrunc Bool
defDetect IORef DetectResult
detectRef (ConsoleLoggingP 'ConfigPhaseArgs
args ConsoleLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (ConsoleLoggingP 'ConfigPhaseArgs)
     (Maybe (WithDisabled LineTruncation))
-> Maybe (WithDisabled LineTruncation)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (ConsoleLoggingP 'ConfigPhaseArgs)
  (Maybe (WithDisabled LineTruncation))
#lineTrunc) (ConsoleLoggingToml
toml ConsoleLoggingToml
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingToml
     (Maybe (WithDisabled LineTruncation))
-> Maybe (WithDisabled LineTruncation)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingToml
  (Maybe (WithDisabled LineTruncation))
#lineTrunc)

  pure
    $ MkConsoleLoggingP
      { SwitchF 'ConfigPhaseMerged ConsoleLogCmdSwitch
ConsoleLogCmdSwitch
commandLogging :: SwitchF 'ConfigPhaseMerged ConsoleLogCmdSwitch
commandLogging :: ConsoleLogCmdSwitch
commandLogging,
        commandNameTrunc :: ConfigPhaseDisabledMaybeF
  'ConfigPhaseMerged (Truncation 'TruncCommandName)
commandNameTrunc = ConsoleLoggingP 'ConfigPhaseArgs
args ConsoleLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (ConsoleLoggingP 'ConfigPhaseArgs)
     (Maybe (WithDisabled (Truncation 'TruncCommandName)))
-> Maybe (WithDisabled (Truncation 'TruncCommandName))
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (ConsoleLoggingP 'ConfigPhaseArgs)
  (Maybe (WithDisabled (Truncation 'TruncCommandName)))
#commandNameTrunc Maybe (WithDisabled (Truncation 'TruncCommandName))
-> Maybe (WithDisabled (Truncation 'TruncCommandName))
-> Maybe (Truncation 'TruncCommandName)
forall a.
Maybe (WithDisabled a) -> Maybe (WithDisabled a) -> Maybe a
<|?|> ConsoleLoggingToml
toml ConsoleLoggingToml
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingToml
     (Maybe (WithDisabled (Truncation 'TruncCommandName)))
-> Maybe (WithDisabled (Truncation 'TruncCommandName))
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingToml
  (Maybe (WithDisabled (Truncation 'TruncCommandName)))
#commandNameTrunc,
        Maybe (Truncation 'TruncLine)
LineTruncF 'ConfigPhaseMerged
lineTrunc :: LineTruncF 'ConfigPhaseMerged
lineTrunc :: Maybe (Truncation 'TruncLine)
lineTrunc,
        stripControl :: ConfigPhaseF
  'ConfigPhaseMerged (StripControl 'StripControlConsoleLog)
stripControl = ConsoleLoggingP 'ConfigPhaseArgs
args ConsoleLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens
     NoIx
     (ConsoleLoggingP 'ConfigPhaseArgs)
     (Maybe (StripControl 'StripControlConsoleLog))
-> Maybe (StripControl 'StripControlConsoleLog)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  (ConsoleLoggingP 'ConfigPhaseArgs)
  (Maybe (StripControl 'StripControlConsoleLog))
#stripControl Maybe (StripControl 'StripControlConsoleLog)
-> Maybe (StripControl 'StripControlConsoleLog)
-> StripControl 'StripControlConsoleLog
forall a. Default a => Maybe a -> Maybe a -> a
<.> ConsoleLoggingToml
toml ConsoleLoggingToml
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingToml
     (Maybe (StripControl 'StripControlConsoleLog))
-> Maybe (StripControl 'StripControlConsoleLog)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingToml
  (Maybe (StripControl 'StripControlConsoleLog))
#stripControl,
        timerFormat :: ConfigPhaseF 'ConfigPhaseMerged TimerFormat
timerFormat = ConsoleLoggingP 'ConfigPhaseArgs
args ConsoleLoggingP 'ConfigPhaseArgs
-> Optic'
     A_Lens NoIx (ConsoleLoggingP 'ConfigPhaseArgs) (Maybe TimerFormat)
-> Maybe TimerFormat
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx (ConsoleLoggingP 'ConfigPhaseArgs) (Maybe TimerFormat)
#timerFormat Maybe TimerFormat -> Maybe TimerFormat -> TimerFormat
forall a. Default a => Maybe a -> Maybe a -> a
<.> ConsoleLoggingToml
toml ConsoleLoggingToml
-> Optic' A_Lens NoIx ConsoleLoggingToml (Maybe TimerFormat)
-> Maybe TimerFormat
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingToml (Maybe TimerFormat)
#timerFormat
      }
  where
    toml :: ConsoleLoggingToml
toml = ConsoleLoggingToml
-> Maybe ConsoleLoggingToml -> ConsoleLoggingToml
forall a. a -> Maybe a -> a
fromMaybe ConsoleLoggingToml
forall a. Monoid a => a
mempty Maybe ConsoleLoggingToml
mToml
{-# INLINEABLE mergeConsoleLogging #-}

instance DecodeTOML ConsoleLoggingToml where
  tomlDecoder :: Decoder ConsoleLoggingToml
tomlDecoder =
    Maybe ConsoleLogCmdSwitch
-> Maybe (WithDisabled (Truncation 'TruncCommandName))
-> Maybe (WithDisabled LineTruncation)
-> Maybe (StripControl 'StripControlConsoleLog)
-> Maybe TimerFormat
-> ConsoleLoggingToml
SwitchF 'ConfigPhaseToml ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF
     'ConfigPhaseToml (Truncation 'TruncCommandName)
-> LineTruncF 'ConfigPhaseToml
-> ConfigPhaseF
     'ConfigPhaseToml (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF 'ConfigPhaseToml TimerFormat
-> ConsoleLoggingToml
forall (p :: ConfigPhase).
SwitchF p ConsoleLogCmdSwitch
-> ConfigPhaseDisabledMaybeF p (Truncation 'TruncCommandName)
-> LineTruncF p
-> ConfigPhaseF p (StripControl 'StripControlConsoleLog)
-> ConfigPhaseF p TimerFormat
-> ConsoleLoggingP p
MkConsoleLoggingP
      (Maybe ConsoleLogCmdSwitch
 -> Maybe (WithDisabled (Truncation 'TruncCommandName))
 -> Maybe (WithDisabled LineTruncation)
 -> Maybe (StripControl 'StripControlConsoleLog)
 -> Maybe TimerFormat
 -> ConsoleLoggingToml)
-> Decoder (Maybe ConsoleLogCmdSwitch)
-> Decoder
     (Maybe (WithDisabled (Truncation 'TruncCommandName))
      -> Maybe (WithDisabled LineTruncation)
      -> Maybe (StripControl 'StripControlConsoleLog)
      -> Maybe TimerFormat
      -> ConsoleLoggingToml)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder (Maybe ConsoleLogCmdSwitch)
decodeCommandLogging
      Decoder
  (Maybe (WithDisabled (Truncation 'TruncCommandName))
   -> Maybe (WithDisabled LineTruncation)
   -> Maybe (StripControl 'StripControlConsoleLog)
   -> Maybe TimerFormat
   -> ConsoleLoggingToml)
-> Decoder (Maybe (WithDisabled (Truncation 'TruncCommandName)))
-> Decoder
     (Maybe (WithDisabled LineTruncation)
      -> Maybe (StripControl 'StripControlConsoleLog)
      -> Maybe TimerFormat
      -> ConsoleLoggingToml)
forall a b. Decoder (a -> b) -> Decoder a -> Decoder b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe (WithDisabled (Truncation 'TruncCommandName)))
decodeCommandNameTrunc
      Decoder
  (Maybe (WithDisabled LineTruncation)
   -> Maybe (StripControl 'StripControlConsoleLog)
   -> Maybe TimerFormat
   -> ConsoleLoggingToml)
-> Decoder (Maybe (WithDisabled LineTruncation))
-> Decoder
     (Maybe (StripControl 'StripControlConsoleLog)
      -> Maybe TimerFormat -> ConsoleLoggingToml)
forall a b. Decoder (a -> b) -> Decoder a -> Decoder b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe (WithDisabled LineTruncation))
decodeLineTrunc
      Decoder
  (Maybe (StripControl 'StripControlConsoleLog)
   -> Maybe TimerFormat -> ConsoleLoggingToml)
-> Decoder (Maybe (StripControl 'StripControlConsoleLog))
-> Decoder (Maybe TimerFormat -> ConsoleLoggingToml)
forall a b. Decoder (a -> b) -> Decoder a -> Decoder b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe (StripControl 'StripControlConsoleLog))
decodeStripControl
      Decoder (Maybe TimerFormat -> ConsoleLoggingToml)
-> Decoder (Maybe TimerFormat) -> Decoder ConsoleLoggingToml
forall a b. Decoder (a -> b) -> Decoder a -> Decoder b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Decoder (Maybe TimerFormat)
decodeTimerFormat

decodeCommandLogging :: Decoder (Maybe ConsoleLogCmdSwitch)
decodeCommandLogging :: Decoder (Maybe ConsoleLogCmdSwitch)
decodeCommandLogging = Decoder ConsoleLogCmdSwitch
-> Text -> Decoder (Maybe ConsoleLogCmdSwitch)
forall a. Decoder a -> Text -> Decoder (Maybe a)
getFieldOptWith Decoder ConsoleLogCmdSwitch
forall a. DecodeTOML a => Decoder a
tomlDecoder Text
"command"

decodeStripControl :: Decoder (Maybe ConsoleLogStripControl)
decodeStripControl :: Decoder (Maybe (StripControl 'StripControlConsoleLog))
decodeStripControl = Decoder (StripControl 'StripControlConsoleLog)
-> Text -> Decoder (Maybe (StripControl 'StripControlConsoleLog))
forall a. Decoder a -> Text -> Decoder (Maybe a)
getFieldOptWith Decoder (StripControl 'StripControlConsoleLog)
forall a. DecodeTOML a => Decoder a
tomlDecoder Text
"strip-control"

decodeTimerFormat :: Decoder (Maybe TimerFormat)
decodeTimerFormat :: Decoder (Maybe TimerFormat)
decodeTimerFormat = Decoder TimerFormat -> Text -> Decoder (Maybe TimerFormat)
forall a. Decoder a -> Text -> Decoder (Maybe a)
getFieldOptWith Decoder TimerFormat
forall a. DecodeTOML a => Decoder a
tomlDecoder Text
"timer-format"

toEnv :: ConsoleLoggingMerged -> ConsoleLoggingEnv
toEnv :: ConsoleLoggingMerged -> ConsoleLoggingEnv
toEnv ConsoleLoggingMerged
merged =
  MkConsoleLoggingP
    { commandLogging :: SwitchF 'ConfigPhaseEnv ConsoleLogCmdSwitch
commandLogging = ConsoleLoggingMerged
merged ConsoleLoggingMerged
-> Optic' A_Lens NoIx ConsoleLoggingMerged ConsoleLogCmdSwitch
-> ConsoleLogCmdSwitch
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingMerged ConsoleLogCmdSwitch
#commandLogging,
      commandNameTrunc :: ConfigPhaseDisabledMaybeF
  'ConfigPhaseEnv (Truncation 'TruncCommandName)
commandNameTrunc = ConsoleLoggingMerged
merged ConsoleLoggingMerged
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingMerged
     (Maybe (Truncation 'TruncCommandName))
-> Maybe (Truncation 'TruncCommandName)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingMerged
  (Maybe (Truncation 'TruncCommandName))
#commandNameTrunc,
      lineTrunc :: LineTruncF 'ConfigPhaseEnv
lineTrunc = ConsoleLoggingMerged
merged ConsoleLoggingMerged
-> Optic'
     A_Lens NoIx ConsoleLoggingMerged (Maybe (Truncation 'TruncLine))
-> Maybe (Truncation 'TruncLine)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens NoIx ConsoleLoggingMerged (Maybe (Truncation 'TruncLine))
#lineTrunc,
      stripControl :: ConfigPhaseF 'ConfigPhaseEnv (StripControl 'StripControlConsoleLog)
stripControl = ConsoleLoggingMerged
merged ConsoleLoggingMerged
-> Optic'
     A_Lens
     NoIx
     ConsoleLoggingMerged
     (StripControl 'StripControlConsoleLog)
-> StripControl 'StripControlConsoleLog
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
  A_Lens
  NoIx
  ConsoleLoggingMerged
  (StripControl 'StripControlConsoleLog)
#stripControl,
      timerFormat :: ConfigPhaseF 'ConfigPhaseEnv TimerFormat
timerFormat = ConsoleLoggingMerged
merged ConsoleLoggingMerged
-> Optic' A_Lens NoIx ConsoleLoggingMerged TimerFormat
-> TimerFormat
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ConsoleLoggingMerged TimerFormat
#timerFormat
    }