{-# LANGUAGE NoImplicitPrelude #-}

module Stack.Types.GlobalOptsMonoid
  ( GlobalOptsMonoid (..)
  ) where

import           Generics.Deriving.Monoid ( mappenddefault, memptydefault )
import           Stack.Prelude
import           Stack.Types.ConfigMonoid ( ConfigMonoid )
import           Stack.Types.DockerEntrypoint ( DockerEntrypoint )
import           Stack.Types.LockFileBehavior ( LockFileBehavior )
import           Stack.Types.Resolver ( AbstractResolver )

-- | Parsed global command-line options monoid.

data GlobalOptsMonoid = GlobalOptsMonoid
  { GlobalOptsMonoid -> First String
globalMonoidReExecVersion :: !(First String)
    -- ^ Expected re-exec in container version

  , GlobalOptsMonoid -> First DockerEntrypoint
globalMonoidDockerEntrypoint :: !(First DockerEntrypoint)
    -- ^ Data used when Stack is acting as a Docker entrypoint (internal use

    -- only)

  , GlobalOptsMonoid -> First LogLevel
globalMonoidLogLevel     :: !(First LogLevel)
    -- ^ Log level

  , GlobalOptsMonoid -> FirstTrue
globalMonoidTimeInLog    :: !FirstTrue
    -- ^ Whether to include timings in logs.

  , GlobalOptsMonoid -> FirstFalse
globalMonoidRSLInLog     :: !FirstFalse
    -- ^ Whether to include raw snapshot layer (RSL) in logs.

  , GlobalOptsMonoid -> FirstFalse
globalMonoidPlanInLog :: !FirstFalse
    -- ^ Whether to include debug information about the construction of the

    -- build plan in logs.

  , GlobalOptsMonoid -> ConfigMonoid
globalMonoidConfigMonoid :: !ConfigMonoid
    -- ^ Config monoid, for passing into 'loadConfig'

  , GlobalOptsMonoid -> First (Unresolved AbstractResolver)
globalMonoidResolver     :: !(First (Unresolved AbstractResolver))
    -- ^ Resolver override

  , GlobalOptsMonoid -> First String
globalMonoidResolverRoot :: !(First FilePath)
    -- ^ root directory for resolver relative path

  , GlobalOptsMonoid -> First WantedCompiler
globalMonoidCompiler     :: !(First WantedCompiler)
    -- ^ Compiler override

  , GlobalOptsMonoid -> First Bool
globalMonoidTerminal     :: !(First Bool)
    -- ^ We're in a terminal?

  , GlobalOptsMonoid -> StylesUpdate
globalMonoidStyles       :: !StylesUpdate
    -- ^ Stack's output styles

  , GlobalOptsMonoid -> First Int
globalMonoidTermWidth    :: !(First Int)
    -- ^ Terminal width override

  , GlobalOptsMonoid -> First String
globalMonoidStackYaml    :: !(First FilePath)
    -- ^ Override project stack.yaml

  , GlobalOptsMonoid -> First LockFileBehavior
globalMonoidLockFileBehavior :: !(First LockFileBehavior)
    -- ^ See 'globalLockFileBehavior'

  }
  deriving (forall x. GlobalOptsMonoid -> Rep GlobalOptsMonoid x)
-> (forall x. Rep GlobalOptsMonoid x -> GlobalOptsMonoid)
-> Generic GlobalOptsMonoid
forall x. Rep GlobalOptsMonoid x -> GlobalOptsMonoid
forall x. GlobalOptsMonoid -> Rep GlobalOptsMonoid x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GlobalOptsMonoid -> Rep GlobalOptsMonoid x
from :: forall x. GlobalOptsMonoid -> Rep GlobalOptsMonoid x
$cto :: forall x. Rep GlobalOptsMonoid x -> GlobalOptsMonoid
to :: forall x. Rep GlobalOptsMonoid x -> GlobalOptsMonoid
Generic

instance Semigroup GlobalOptsMonoid where
  <> :: GlobalOptsMonoid -> GlobalOptsMonoid -> GlobalOptsMonoid
(<>) = GlobalOptsMonoid -> GlobalOptsMonoid -> GlobalOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a -> a -> a
mappenddefault

instance Monoid GlobalOptsMonoid where
  mempty :: GlobalOptsMonoid
mempty = GlobalOptsMonoid
forall a. (Generic a, Monoid' (Rep a)) => a
memptydefault
  mappend :: GlobalOptsMonoid -> GlobalOptsMonoid -> GlobalOptsMonoid
mappend = GlobalOptsMonoid -> GlobalOptsMonoid -> GlobalOptsMonoid
forall a. Semigroup a => a -> a -> a
(<>)