Skip to content

Commit 16ec9c9

Browse files
committed
Fix help for stack config
1 parent f0c3e72 commit 16ec9c9

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
@@ -30,7 +30,8 @@ import Pantry (loadSnapshot)
3030
import Path
3131
import qualified RIO.Map as Map
3232
import RIO.Process (envVarsL)
33-
import Stack.Config (makeConcreteResolver, getProjectConfig, getImplicitGlobalProjectDir)
33+
import Stack.Config (makeConcreteResolver, getProjectConfig,
34+
getImplicitGlobalProjectDir)
3435
import Stack.Constants
3536
import Stack.Types.Config
3637
import Stack.Types.Resolver
@@ -79,7 +80,8 @@ cfgCmdSet cmd = do
7980
if config' == config
8081
then logInfo
8182
(fromString (toFilePath configFilePath) <>
82-
" already contained the intended configuration and remains unchanged.")
83+
" already contained the intended configuration and remains \
84+
\unchanged.")
8385
else do
8486
writeBinaryFileAtomic configFilePath (byteString (Yaml.encode config'))
8587
logInfo (fromString (toFilePath configFilePath) <> " has been updated.")
@@ -114,60 +116,67 @@ cfgCmdEnvName :: String
114116
cfgCmdEnvName = "env"
115117

116118
configCmdSetParser :: OA.Parser ConfigCmdSet
117-
configCmdSetParser =
118-
OA.hsubparser $
119-
mconcat
120-
[ OA.command
121-
"resolver"
122-
(OA.info
123-
(ConfigCmdSetResolver <$>
124-
OA.argument
125-
readAbstractResolver
126-
(OA.metavar "RESOLVER" <>
127-
OA.help "E.g. \"nightly\" or \"lts-7.2\""))
128-
(OA.progDesc
129-
"Change the resolver of the current project. See https://docs.haskellstack.org/en/stable/yaml_configuration/#resolver for more info."))
130-
, OA.command
131-
(T.unpack configMonoidSystemGHCName)
132-
(OA.info
133-
(ConfigCmdSetSystemGhc <$> scopeFlag <*> boolArgument)
134-
(OA.progDesc
135-
"Configure whether stack should use a system GHC installation or not."))
136-
, OA.command
137-
(T.unpack configMonoidInstallGHCName)
138-
(OA.info
139-
(ConfigCmdSetInstallGhc <$> scopeFlag <*> boolArgument)
140-
(OA.progDesc
141-
"Configure whether stack should automatically install GHC when necessary."))
142-
]
119+
configCmdSetParser = OA.hsubparser $
120+
mconcat
121+
[ OA.command "resolver"
122+
( OA.info
123+
(ConfigCmdSetResolver <$>
124+
OA.argument
125+
readAbstractResolver
126+
(OA.metavar "SNAPSHOT" <>
127+
OA.help "E.g. \"nightly\" or \"lts-7.2\""))
128+
(OA.progDesc
129+
"Change the resolver of the current project."))
130+
, OA.command (T.unpack configMonoidSystemGHCName)
131+
( OA.info
132+
(ConfigCmdSetSystemGhc <$> scopeFlag <*> boolArgument)
133+
(OA.progDesc
134+
"Configure whether Stack should use a system GHC installation \
135+
\or not."))
136+
, OA.command (T.unpack configMonoidInstallGHCName)
137+
( OA.info
138+
(ConfigCmdSetInstallGhc <$> scopeFlag <*> boolArgument)
139+
(OA.progDesc
140+
"Configure whether Stack should automatically install GHC when \
141+
\necessary."))
142+
]
143143

144144
scopeFlag :: OA.Parser CommandScope
145-
scopeFlag =
146-
OA.flag
147-
CommandScopeProject
148-
CommandScopeGlobal
149-
(OA.long "global" <>
150-
OA.help
151-
"Modify the global configuration (typically at \"~/.stack/config.yaml\") instead of the project stack.yaml.")
145+
scopeFlag = OA.flag
146+
CommandScopeProject
147+
CommandScopeGlobal
148+
( OA.long "global"
149+
<> OA.help
150+
"Modify the user-specific global configuration file ('config.yaml') \
151+
\instead of the project-level configuration file ('stack.yaml')."
152+
)
152153

153154
readBool :: OA.ReadM Bool
154155
readBool = do
155-
s <- OA.readerAsk
156-
case s of
157-
"true" -> return True
158-
"false" -> return False
159-
_ -> OA.readerError ("Invalid value " ++ show s ++ ": Expected \"true\" or \"false\"")
156+
s <- OA.readerAsk
157+
case s of
158+
"true" -> return True
159+
"false" -> return False
160+
_ -> OA.readerError ("Invalid value " ++ show s ++
161+
": Expected \"true\" or \"false\"")
160162

161163
boolArgument :: OA.Parser Bool
162-
boolArgument = OA.argument readBool (OA.metavar "true|false" <> OA.completeWith ["true", "false"])
164+
boolArgument = OA.argument
165+
readBool
166+
( OA.metavar "true|false"
167+
<> OA.completeWith ["true", "false"]
168+
)
163169

164170
configCmdEnvParser :: OA.Parser EnvSettings
165171
configCmdEnvParser = EnvSettings
166172
<$> boolFlags True "locals" "include local package information" mempty
167-
<*> boolFlags True "ghc-package-path" "set GHC_PACKAGE_PATH variable" mempty
173+
<*> boolFlags True
174+
"ghc-package-path" "set GHC_PACKAGE_PATH environment variable" mempty
168175
<*> boolFlags True "stack-exe" "set STACK_EXE environment variable" mempty
169-
<*> boolFlags False "locale-utf8" "set the GHC_CHARENC environment variable to UTF8" mempty
170-
<*> boolFlags False "keep-ghc-rts" "keep any GHC_RTS environment variables" mempty
176+
<*> boolFlags False
177+
"locale-utf8" "set the GHC_CHARENC environment variable to UTF-8" mempty
178+
<*> boolFlags False
179+
"keep-ghc-rts" "keep any GHCRTS environment variable" mempty
171180

172181
data EnvVarAction = EVASet !Text | EVAUnset
173182
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)