Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove runner prefix from Runner field names #6432

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ configFromConfigMonoid
useAnsi <- liftIO $ hNowSupportsANSI stderr
let stylesUpdate' = (configRunner' ^. stylesUpdateL) <>
configMonoid.configMonoidStyles
useColor' = configRunner'.runnerUseColor
useColor' = configRunner'.useColor
mUseColor = do
colorWhen <- getFirst configMonoid.configMonoidColorWhen
pure $ case colorWhen of
Expand All @@ -449,7 +449,7 @@ configFromConfigMonoid
& processContextL .~ origEnv
& stylesUpdateL .~ stylesUpdate'
& useColorL .~ useColor''
go = configRunner'.runnerGlobalOpts
go = configRunner'.globalOpts
pic <-
case getFirst configMonoid.configMonoidPackageIndex of
Nothing ->
Expand Down
21 changes: 11 additions & 10 deletions src/Stack/Runners.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}

-- | Utilities for running stack commands.
--
Expand Down Expand Up @@ -235,12 +236,12 @@ withRunnerGlobal go inner = do
let update = go.stylesUpdate
withNewLogFunc go useColor update $ \logFunc -> do
runRIO Runner
{ runnerGlobalOpts = go
, runnerUseColor = useColor
, runnerLogFunc = logFunc
, runnerTermWidth = termWidth
, runnerProcessContext = menv
, runnerDockerEntrypointMVar = dockerEntrypointMVar
{ globalOpts = go
, useColor = useColor
, logFunc = logFunc
, termWidth = termWidth
, processContext = menv
, dockerEntrypointMVar = dockerEntrypointMVar
} inner
where
clipWidth w
Expand Down
42 changes: 20 additions & 22 deletions src/Stack/Types/Runner.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE OverloadedRecordDot #-}

module Stack.Types.Runner
Expand All @@ -16,8 +17,8 @@ module Stack.Types.Runner

import RIO.Process ( HasProcessContext (..), ProcessContext )
import Stack.Prelude
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
import qualified Stack.Types.GlobalOpts as GlobalOpts ( GlobalOpts (..) )
import Stack.Types.GlobalOpts ( GlobalOpts )
import qualified Stack.Types.GlobalOpts as GlobalOpts
import Stack.Types.LockFileBehavior ( LockFileBehavior )
import Stack.Types.StackYamlLoc ( StackYamlLoc )

Expand All @@ -26,20 +27,20 @@ import Stack.Types.StackYamlLoc ( StackYamlLoc )
-- execution, and the MVar used to ensure that the Docker entrypoint is
-- performed exactly once.
data Runner = Runner
{ runnerGlobalOpts :: !GlobalOpts
, runnerUseColor :: !Bool
, runnerLogFunc :: !LogFunc
, runnerTermWidth :: !Int
, runnerProcessContext :: !ProcessContext
, runnerDockerEntrypointMVar :: !(MVar Bool)
{ globalOpts :: !GlobalOpts
, useColor :: !Bool
, logFunc :: !LogFunc
, termWidth :: !Int
, processContext :: !ProcessContext
, dockerEntrypointMVar :: !(MVar Bool)
}

instance HasLogFunc Runner where
logFuncL = lens (.runnerLogFunc) (\x y -> x { runnerLogFunc = y })
logFuncL = lens (.logFunc) (\x y -> x { logFunc = y })

instance HasProcessContext Runner where
processContextL =
lens (.runnerProcessContext) (\x y -> x { runnerProcessContext = y })
lens (.processContext) (\x y -> x { processContext = y })

instance HasRunner Runner where
runnerL = id
Expand All @@ -48,14 +49,14 @@ instance HasStylesUpdate Runner where
stylesUpdateL = globalOptsL . lens
(.stylesUpdate)
(\x y -> x { GlobalOpts.stylesUpdate = y })

instance HasTerm Runner where
useColorL = lens (.runnerUseColor) (\x y -> x { runnerUseColor = y })
termWidthL = lens (.runnerTermWidth) (\x y -> x { runnerTermWidth = y })
useColorL = lens (.useColor) (\x y -> x { useColor = y })
termWidthL = lens (.termWidth) (\x y -> x { termWidth = y })

instance HasDockerEntrypointMVar Runner where
dockerEntrypointMVarL = lens
(.runnerDockerEntrypointMVar)
(\x y -> x { runnerDockerEntrypointMVar = y })
dockerEntrypointMVarL =
lens (.dockerEntrypointMVar) (\x y -> x { dockerEntrypointMVar = y })

-- | Class for environment values which have a 'Runner'.
class (HasProcessContext env, HasLogFunc env) => HasRunner env where
Expand All @@ -67,21 +68,18 @@ class HasRunner env => HasDockerEntrypointMVar env where

stackYamlLocL :: HasRunner env => Lens' env StackYamlLoc
stackYamlLocL =
globalOptsL . lens (.stackYaml) (\x y -> x { stackYaml = y })
globalOptsL . lens (.stackYaml) (\x y -> x { GlobalOpts.stackYaml = y })

lockFileBehaviorL :: HasRunner env => SimpleGetter env LockFileBehavior
lockFileBehaviorL = globalOptsL . to (.lockFileBehavior)

globalOptsL :: HasRunner env => Lens' env GlobalOpts
globalOptsL = runnerL . lens
(.runnerGlobalOpts)
(\x y -> x { runnerGlobalOpts = y })
globalOptsL = runnerL . lens (.globalOpts) (\x y -> x { globalOpts = y })

-- | See 'globalTerminal'
terminalL :: HasRunner env => Lens' env Bool
terminalL = globalOptsL . lens
(.terminal)
(\x y -> x { terminal = y })
terminalL =
globalOptsL . lens (.terminal) (\x y -> x { GlobalOpts.terminal = y })

-- | See 'globalReExecVersion'
reExecL :: HasRunner env => SimpleGetter env Bool
Expand Down
Loading