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

Fix #4205 (step 6): Alias 'colour' for 'color' #4264

Merged
merged 1 commit into from
Aug 27, 2018
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
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Other enhancements:
non-project-specific yaml configuration parameter, allows a stack user to
redefine the default styles that stack uses to color some of its output. See
`stack --help` for more information.
* British English spelling of 'color' (colour) accepted as an alias for
`--color`, `--stack-colors`, `stack ls stack-colors` at the command line and
for `color:` and `stack-colors:` in yaml configuration files.
* New build option `--ddump-dir`. (See [#4225](https://github.com/commercialhaskell/stack/issues/4225))
* Stack parses and respects the `preferred-versions` information from
Hackage for choosing latest version of a package in some cases,
Expand Down
10 changes: 9 additions & 1 deletion doc/yaml_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,9 @@ The color use can also be set at the command line using the equivalent
`--color=<WHEN>` global option. Color use set at the command line takes
precedence over that set in a yaml configuration file.

(The British English spelling (colour) is also accepted. In yaml configuration
files, the American spelling is the alternative that has priority.)

### stack-colors

Stack uses styles to format some of its output. The default styles do not work
Expand Down Expand Up @@ -983,4 +986,9 @@ terminal theme might wish to set the styles as follows:
```yaml
stack-colors: error=31:good=32:shell=35:dir=34:recommendation=32:target=95:module=35:package-component=95
```
The styles can also be set at the command line using the equivalent `--stack-colors=<STYLES>` global option. Styles set at the command line take precedence over those set in a yaml configuration file.
The styles can also be set at the command line using the equivalent `--stack-colors=<STYLES>`
global option. Styles set at the command line take precedence over those set in
a yaml configuration file.

(The British English spelling (colour) is also accepted. In yaml configuration
files, the American spelling is the alternative that has priority.)
9 changes: 8 additions & 1 deletion src/Stack/Ls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ lsStylesCmd :: OA.Mod OA.CommandFields LsCmds
lsStylesCmd =
OA.command
"stack-colors"
(OA.info lsStylesOptsParser (OA.progDesc "View stack's output styles"))
(OA.info lsStylesOptsParser
(OA.progDesc "View stack's output styles"))
<>
OA.command
"stack-colours"
(OA.info lsStylesOptsParser
(OA.progDesc "View stack's output styles (alias for \
\'stack-colors')"))

data Snapshot = Snapshot
{ snapId :: Text
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Options/ConfigParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ configOptsParser currentDir hide0 =
hide)
<*> optionalFirst (option readColorWhen
( long "color"
<> long "colour"
<> metavar "WHEN"
<> completeWith ["always", "never", "auto"]
<> help "Specify when to use color in output; WHEN is 'always', \
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Options/GlobalParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ globalOptsParser currentDir kind defLogLevel =
hide <*>
option readStyles
(long "stack-colors" <>
long "stack-colours" <>
metavar "STYLES" <>
value mempty <>
help "Specify stack's output styles; STYLES is a colon-delimited \
Expand Down
26 changes: 20 additions & 6 deletions src/Stack/Types/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,16 @@ parseConfigMonoidObject rootDir obj = do
configMonoidDumpLogs <- First <$> obj ..:? configMonoidDumpLogsName
configMonoidSaveHackageCreds <- First <$> obj ..:? configMonoidSaveHackageCredsName
configMonoidHackageBaseUrl <- First <$> obj ..:? configMonoidHackageBaseUrlName
configMonoidColorWhen <- First <$> obj ..:? configMonoidColorWhenName
configMonoidStyles <- fromMaybe mempty <$> obj ..:? configMonoidStylesName

configMonoidColorWhenUS <- obj ..:? configMonoidColorWhenUSName
configMonoidColorWhenGB <- obj ..:? configMonoidColorWhenGBName
let configMonoidColorWhen = First $ configMonoidColorWhenUS
<|> configMonoidColorWhenGB

configMonoidStylesUS <- obj ..:? configMonoidStylesUSName
configMonoidStylesGB <- obj ..:? configMonoidStylesGBName
let configMonoidStyles = fromMaybe mempty $ configMonoidStylesUS
<|> configMonoidStylesGB

return ConfigMonoid {..}
where
Expand Down Expand Up @@ -998,11 +1006,17 @@ configMonoidSaveHackageCredsName = "save-hackage-creds"
configMonoidHackageBaseUrlName :: Text
configMonoidHackageBaseUrlName = "hackage-base-url"

configMonoidColorWhenName :: Text
configMonoidColorWhenName = "color"
configMonoidColorWhenUSName :: Text
configMonoidColorWhenUSName = "color"

configMonoidColorWhenGBName :: Text
configMonoidColorWhenGBName = "colour"

configMonoidStylesUSName :: Text
configMonoidStylesUSName = "stack-colors"

configMonoidStylesName :: Text
configMonoidStylesName = "stack-colors"
configMonoidStylesGBName :: Text
configMonoidStylesGBName = "stack-colours"

data ConfigException
= ParseConfigFileException (Path Abs File) ParseException
Expand Down