{-# LANGUAGE NoImplicitPrelude #-}

module Stack.Types.GlobalOpts
  ( GlobalOpts (..)
  , globalOptsBuildOptsMonoidL
  ) where

import          Stack.Prelude
import          Stack.Types.BuildOpts ( BuildOptsMonoid )
import          Stack.Types.ConfigMonoid ( ConfigMonoid (..) )
import          Stack.Types.DockerEntrypoint ( DockerEntrypoint )
import          Stack.Types.LockFileBehavior ( LockFileBehavior )
import          Stack.Types.Resolver ( AbstractResolver )
import          Stack.Types.StackYamlLoc ( StackYamlLoc )

-- | Parsed global command-line options.

data GlobalOpts = GlobalOpts
  { GlobalOpts -> Maybe String
globalReExecVersion :: !(Maybe String)
    -- ^ Expected re-exec in container version

  , GlobalOpts -> Maybe DockerEntrypoint
globalDockerEntrypoint :: !(Maybe DockerEntrypoint)
    -- ^ Data used when Stack is acting as a Docker entrypoint (internal use

    -- only)

  , GlobalOpts -> LogLevel
globalLogLevel     :: !LogLevel -- ^ Log level

  , GlobalOpts -> Bool
globalTimeInLog    :: !Bool -- ^ Whether to include timings in logs.

  , GlobalOpts -> Bool
globalRSLInLog     :: !Bool
    -- ^ Whether to include raw snapshot layer (RSL) in logs.

  , GlobalOpts -> Bool
globalPlanInLog :: !Bool
    -- ^ Whether to include debug information about the construction of the

    -- build plan in logs.

  , GlobalOpts -> ConfigMonoid
globalConfigMonoid :: !ConfigMonoid
    -- ^ Config monoid, for passing into 'loadConfig'

  , GlobalOpts -> Maybe AbstractResolver
globalResolver     :: !(Maybe AbstractResolver) -- ^ Resolver override

  , GlobalOpts -> Maybe WantedCompiler
globalCompiler     :: !(Maybe WantedCompiler) -- ^ Compiler override

  , GlobalOpts -> Bool
globalTerminal     :: !Bool -- ^ We're in a terminal?

  , GlobalOpts -> StylesUpdate
globalStylesUpdate :: !StylesUpdate -- ^ SGR (Ansi) codes for styles

  , GlobalOpts -> Maybe Int
globalTermWidth    :: !(Maybe Int) -- ^ Terminal width override

  , GlobalOpts -> StackYamlLoc
globalStackYaml    :: !StackYamlLoc -- ^ Override project stack.yaml

  , GlobalOpts -> LockFileBehavior
globalLockFileBehavior :: !LockFileBehavior
  }
  deriving Int -> GlobalOpts -> ShowS
[GlobalOpts] -> ShowS
GlobalOpts -> String
(Int -> GlobalOpts -> ShowS)
-> (GlobalOpts -> String)
-> ([GlobalOpts] -> ShowS)
-> Show GlobalOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GlobalOpts -> ShowS
showsPrec :: Int -> GlobalOpts -> ShowS
$cshow :: GlobalOpts -> String
show :: GlobalOpts -> String
$cshowList :: [GlobalOpts] -> ShowS
showList :: [GlobalOpts] -> ShowS
Show

globalOptsBuildOptsMonoidL :: Lens' GlobalOpts BuildOptsMonoid
globalOptsBuildOptsMonoidL :: Lens' GlobalOpts BuildOptsMonoid
globalOptsBuildOptsMonoidL =
  (GlobalOpts -> ConfigMonoid)
-> (GlobalOpts -> ConfigMonoid -> GlobalOpts)
-> Lens GlobalOpts GlobalOpts ConfigMonoid ConfigMonoid
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens
    GlobalOpts -> ConfigMonoid
globalConfigMonoid
    (\GlobalOpts
x ConfigMonoid
y -> GlobalOpts
x { globalConfigMonoid :: ConfigMonoid
globalConfigMonoid = ConfigMonoid
y })
  ((ConfigMonoid -> f ConfigMonoid) -> GlobalOpts -> f GlobalOpts)
-> ((BuildOptsMonoid -> f BuildOptsMonoid)
    -> ConfigMonoid -> f ConfigMonoid)
-> (BuildOptsMonoid -> f BuildOptsMonoid)
-> GlobalOpts
-> f GlobalOpts
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  (ConfigMonoid -> BuildOptsMonoid)
-> (ConfigMonoid -> BuildOptsMonoid -> ConfigMonoid)
-> Lens ConfigMonoid ConfigMonoid BuildOptsMonoid BuildOptsMonoid
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens
    ConfigMonoid -> BuildOptsMonoid
configMonoidBuildOpts
    (\ConfigMonoid
x BuildOptsMonoid
y -> ConfigMonoid
x { configMonoidBuildOpts :: BuildOptsMonoid
configMonoidBuildOpts = BuildOptsMonoid
y })