Skip to content

Commit 4749864

Browse files
authored
Merge pull request #5827 from mpilgrem/envHelp
Fix help for `stack config`
2 parents 02e4a52 + 16ec9c9 commit 4749864

File tree

2 files changed

+54
-45
lines changed

2 files changed

+54
-45
lines changed

src/Stack/ConfigCmd.hs

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ import Pantry (loadSnapshot)
3131
import Path
3232
import qualified RIO.Map as Map
3333
import RIO.Process (envVarsL)
34-
import Stack.Config (makeConcreteResolver, getProjectConfig, getImplicitGlobalProjectDir)
34+
import Stack.Config (makeConcreteResolver, getProjectConfig,
35+
getImplicitGlobalProjectDir)
3536
import Stack.Constants
3637
import Stack.Types.Config
3738
import Stack.Types.Resolver
@@ -82,7 +83,8 @@ cfgCmdSet cmd = do
8283
if config' == config
8384
then logInfo
8485
(fromString (toFilePath configFilePath) <>
85-
" already contained the intended configuration and remains unchanged.")
86+
" already contained the intended configuration and remains \
87+
\unchanged.")
8688
else do
8789
let configLines = yamlLines rawConfig
8890
either
@@ -125,60 +127,67 @@ cfgCmdEnvName :: String
125127
cfgCmdEnvName = "env"
126128

127129
configCmdSetParser :: OA.Parser ConfigCmdSet
128-
configCmdSetParser =
129-
OA.hsubparser $
130-
mconcat
131-
[ OA.command
132-
"resolver"
133-
(OA.info
134-
(ConfigCmdSetResolver <$>
135-
OA.argument
136-
readAbstractResolver
137-
(OA.metavar "RESOLVER" <>
138-
OA.help "E.g. \"nightly\" or \"lts-7.2\""))
139-
(OA.progDesc
140-
"Change the resolver of the current project. See https://docs.haskellstack.org/en/stable/yaml_configuration/#resolver for more info."))
141-
, OA.command
142-
(T.unpack configMonoidSystemGHCName)
143-
(OA.info
144-
(ConfigCmdSetSystemGhc <$> scopeFlag <*> boolArgument)
145-
(OA.progDesc
146-
"Configure whether stack should use a system GHC installation or not."))
147-
, OA.command
148-
(T.unpack configMonoidInstallGHCName)
149-
(OA.info
150-
(ConfigCmdSetInstallGhc <$> scopeFlag <*> boolArgument)
151-
(OA.progDesc
152-
"Configure whether stack should automatically install GHC when necessary."))
153-
]
130+
configCmdSetParser = OA.hsubparser $
131+
mconcat
132+
[ OA.command "resolver"
133+
( OA.info
134+
(ConfigCmdSetResolver <$>
135+
OA.argument
136+
readAbstractResolver
137+
(OA.metavar "SNAPSHOT" <>
138+
OA.help "E.g. \"nightly\" or \"lts-7.2\""))
139+
(OA.progDesc
140+
"Change the resolver of the current project."))
141+
, OA.command (T.unpack configMonoidSystemGHCName)
142+
( OA.info
143+
(ConfigCmdSetSystemGhc <$> scopeFlag <*> boolArgument)
144+
(OA.progDesc
145+
"Configure whether Stack should use a system GHC installation \
146+
\or not."))
147+
, OA.command (T.unpack configMonoidInstallGHCName)
148+
( OA.info
149+
(ConfigCmdSetInstallGhc <$> scopeFlag <*> boolArgument)
150+
(OA.progDesc
151+
"Configure whether Stack should automatically install GHC when \
152+
\necessary."))
153+
]
154154

155155
scopeFlag :: OA.Parser CommandScope
156-
scopeFlag =
157-
OA.flag
158-
CommandScopeProject
159-
CommandScopeGlobal
160-
(OA.long "global" <>
161-
OA.help
162-
"Modify the global configuration (typically at \"~/.stack/config.yaml\") instead of the project stack.yaml.")
156+
scopeFlag = OA.flag
157+
CommandScopeProject
158+
CommandScopeGlobal
159+
( OA.long "global"
160+
<> OA.help
161+
"Modify the user-specific global configuration file ('config.yaml') \
162+
\instead of the project-level configuration file ('stack.yaml')."
163+
)
163164

164165
readBool :: OA.ReadM Bool
165166
readBool = do
166-
s <- OA.readerAsk
167-
case s of
168-
"true" -> return True
169-
"false" -> return False
170-
_ -> OA.readerError ("Invalid value " ++ show s ++ ": Expected \"true\" or \"false\"")
167+
s <- OA.readerAsk
168+
case s of
169+
"true" -> return True
170+
"false" -> return False
171+
_ -> OA.readerError ("Invalid value " ++ show s ++
172+
": Expected \"true\" or \"false\"")
171173

172174
boolArgument :: OA.Parser Bool
173-
boolArgument = OA.argument readBool (OA.metavar "true|false" <> OA.completeWith ["true", "false"])
175+
boolArgument = OA.argument
176+
readBool
177+
( OA.metavar "true|false"
178+
<> OA.completeWith ["true", "false"]
179+
)
174180

175181
configCmdEnvParser :: OA.Parser EnvSettings
176182
configCmdEnvParser = EnvSettings
177183
<$> boolFlags True "locals" "include local package information" mempty
178-
<*> boolFlags True "ghc-package-path" "set GHC_PACKAGE_PATH variable" mempty
184+
<*> boolFlags True
185+
"ghc-package-path" "set GHC_PACKAGE_PATH environment variable" mempty
179186
<*> boolFlags True "stack-exe" "set STACK_EXE environment variable" mempty
180-
<*> boolFlags False "locale-utf8" "set the GHC_CHARENC environment variable to UTF8" mempty
181-
<*> boolFlags False "keep-ghc-rts" "keep any GHC_RTS environment variables" mempty
187+
<*> boolFlags False
188+
"locale-utf8" "set the GHC_CHARENC environment variable to UTF-8" mempty
189+
<*> boolFlags False
190+
"keep-ghc-rts" "keep any GHCRTS environment variable" mempty
182191

183192
data EnvVarAction = EVASet !Text | EVAUnset
184193
deriving Show

src/main/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ commandLineHandler currentDir progName isInterpreter = complicatedOptions
397397
"Subcommands for accessing and modifying configuration values"
398398
(do
399399
addCommand' ConfigCmd.cfgCmdSetName
400-
"Sets a field in the project's stack.yaml to value"
400+
"Sets a key in YAML configuration file to value"
401401
(withConfig NoReexec . cfgCmdSet)
402402
configCmdSetParser
403403
addCommand' ConfigCmd.cfgCmdEnvName

0 commit comments

Comments
 (0)