summaryrefslogtreecommitdiff
path: root/python/samba
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-08-17 13:15:15 +1200
committerDouglas Bagnall <dbagnall@samba.org>2022-09-06 21:12:36 +0000
commit37f92c6cc69b220439aef0c687c92a8e6baeb211 (patch)
treee138df84a97568dcdfc3163e8b6ce9bcf925955d /python/samba
parent664653b8d14cbe21c954d248b2bb5ef0d2d60043 (diff)
downloadsamba-37f92c6cc69b220439aef0c687c92a8e6baeb211.tar.gz
samba-37f92c6cc69b220439aef0c687c92a8e6baeb211.tar.bz2
samba-37f92c6cc69b220439aef0c687c92a8e6baeb211.zip
samba-tool visualise: expand set of --color switches
To match convention, and elsewhere. We can't easily use colour.is_colour_wanted() because we could (via --output) be intending to write to a file that isn't open yet, so we have no .isatty() to query. Also, because --color-scheme implies --color (as documented in --help), it trumps most 'auto' checks, but not NO_COLOR. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Diffstat (limited to 'python/samba')
-rw-r--r--python/samba/netcmd/visualize.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/python/samba/netcmd/visualize.py b/python/samba/netcmd/visualize.py
index 49e64794131..ea8e696ee61 100644
--- a/python/samba/netcmd/visualize.py
+++ b/python/samba/netcmd/visualize.py
@@ -57,7 +57,8 @@ COMMON_OPTIONS = [
Option("--utf8", help="Use utf-8 Unicode characters",
action='store_true'),
Option("--color", help="use color (yes, no, auto)",
- choices=['yes', 'no', 'auto']),
+ choices=['yes', 'no', 'auto', 'always', 'never', 'force',
+ 'none', 'if-tty', 'tty']),
Option("--color-scheme", help=("use this colour scheme "
"(implies --color=yes)"),
choices=list(COLOUR_SETS.keys())),
@@ -154,12 +155,15 @@ class GraphCommand(Command):
"""Heuristics to work out the colour scheme for distance matrices.
Returning None means no colour, otherwise it sould be a colour
from graph.COLOUR_SETS"""
- if color == 'no':
+ if color in ('no', 'never', 'none'):
return None
- if color == 'auto':
+ if color in ('auto', 'tty', 'if-tty', None):
if os.environ.get('NO_COLOR'):
return None
+ if color_scheme is not None:
+ # --color-scheme usually implies --color=yes.
+ return color_scheme
if isinstance(output, str) and output != '-':
return None
if not self.outf.isatty():