From 144415f6fa369a593ca8b1a3151e539d845dfe43 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 14 Jul 2020 12:22:11 -0700 Subject: [PATCH] ;cli: improve --color help --- doc/common.m4 | 6 ++++++ hledger/Hledger/Cli/CliOptions.hs | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/common.m4 b/doc/common.m4 index 2d55e6442..916adbc81 100644 --- a/doc/common.m4 +++ b/doc/common.m4 @@ -161,6 +161,12 @@ m4_define({{_reportingoptions_}}, {{ : generate future transactions from [periodic transaction](journal.html#periodic-transactions) rules, for the next 6 months or till report end date. In hledger-ui, also make ordinary future transactions visible. +`--color=always|yes|never|no|auto (or --colour=...)` +: 'auto' is the default, it tries to use ANSI color codes in terminal output when supported. +: 'always' or 'yes' forces color on, useful when piping output, eg into 'less -R'. +: 'never' or 'no' forces color off. +: A NO_COLOR environment variable also disables color, overriding this option. + When a reporting option appears more than once in the command line, the last one takes precedence. Some reporting options can also be written as [query arguments](#queries). diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 550770bbb..c1c7a1f25 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -191,13 +191,12 @@ reportflags = [ -- general output-related - ,flagReq ["color","colour"] (\s opts -> Right $ setopt "color" s opts) "always|never|auto" + ,flagReq ["color","colour"] (\s opts -> Right $ setopt "color" s opts) "always|yes|never|no|auto" (unwords - ["When to use color (or colour) in terminal output." - ,"'auto' is the default; it tries to enable color when the terminal is color-supporting and interactive." - ,"'always' or 'yes' forces color on, useful eg when piping output into 'less -R'." + ["'auto' is the default, it tries to use ANSI color codes in terminal output when supported." + ,"'always' or 'yes' forces color on, useful when piping output, eg into 'less -R'." ,"'never' or 'no' forces color off." - ,"A NO_COLOR environment variable will also force color off, overriding this option." + ,"A NO_COLOR environment variable also disables color, overriding this option." ]) ]