diff --git a/ChangeLog.md b/ChangeLog.md index 4e7a18d5b2..c0b42143ee 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -26,6 +26,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)) Bug fixes: diff --git a/doc/yaml_configuration.md b/doc/yaml_configuration.md index 4ed369e8c8..6ced5382be 100644 --- a/doc/yaml_configuration.md +++ b/doc/yaml_configuration.md @@ -1025,6 +1025,9 @@ The color use can also be set at the command line using the equivalent `--color=` 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 @@ -1053,4 +1056,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=` 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=` +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.) diff --git a/src/Stack/Ls.hs b/src/Stack/Ls.hs index 4187721934..f3fff94216 100644 --- a/src/Stack/Ls.hs +++ b/src/Stack/Ls.hs @@ -133,7 +133,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 diff --git a/src/Stack/Options/ConfigParser.hs b/src/Stack/Options/ConfigParser.hs index 7a9b284e8b..19b676bf95 100644 --- a/src/Stack/Options/ConfigParser.hs +++ b/src/Stack/Options/ConfigParser.hs @@ -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', \ diff --git a/src/Stack/Options/GlobalParser.hs b/src/Stack/Options/GlobalParser.hs index 73ce7b7a0f..2b10cf0733 100644 --- a/src/Stack/Options/GlobalParser.hs +++ b/src/Stack/Options/GlobalParser.hs @@ -35,6 +35,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 \ diff --git a/src/Stack/Types/Config.hs b/src/Stack/Types/Config.hs index fb7e4ef8e1..876518549a 100644 --- a/src/Stack/Types/Config.hs +++ b/src/Stack/Types/Config.hs @@ -891,8 +891,16 @@ parseConfigMonoidObject rootDir obj = do configMonoidSaveHackageCreds <- First <$> obj ..:? configMonoidSaveHackageCredsName configMonoidHackageBaseUrl <- First <$> obj ..:? configMonoidHackageBaseUrlName configMonoidIgnoreRevisionMismatch <- First <$> obj ..:? configMonoidIgnoreRevisionMismatchName - configMonoidColorWhen <- First <$> obj ..:? configMonoidColorWhenName - configMonoidStyles <- fromMaybe mempty <$> obj ..:? configMonoidStylesName + + configMonoidColorWhenPrimary <- obj ..:? configMonoidColorWhenName + configMonoidColorWhenAlternative <- obj ..:? configMonoidColorWhenAlternativeName + let configMonoidColorWhen = First $ configMonoidColorWhenPrimary + <|> configMonoidColorWhenAlternative + + configMonoidStylesPrimary <- obj ..:? configMonoidStylesName + configMonoidStylesAlternative <- obj ..:? configMonoidStylesAlternativeName + let configMonoidStyles = fromMaybe mempty $ configMonoidStylesPrimary + <|> configMonoidStylesAlternative return ConfigMonoid {..} where @@ -1041,9 +1049,15 @@ configMonoidIgnoreRevisionMismatchName = "ignore-revision-mismatch" configMonoidColorWhenName :: Text configMonoidColorWhenName = "color" +configMonoidColorWhenAlternativeName :: Text +configMonoidColorWhenAlternativeName = "colour" + configMonoidStylesName :: Text configMonoidStylesName = "stack-colors" +configMonoidStylesAlternativeName :: Text +configMonoidStylesAlternativeName = "stack-colours" + data ConfigException = ParseConfigFileException (Path Abs File) ParseException | ParseCustomSnapshotException Text ParseException