Verified Commit 0c4c2b38 authored by Antoine Beaupré's avatar Antoine Beaupré
Browse files

comply with the NO_COLOR informal standard

In that standard, the presence of the NO_COLOR environment variable
disables color escape sequences in the output.

See for details.
parent 95ffcd1a
......@@ -33,6 +33,7 @@ along with this program. If not, see <>.
import argparse
import datetime
import logging
import os
import sys
# also considered colorama and crayons
......@@ -98,7 +99,8 @@ def arg_parser():
help='end of working day, in hours [default: %(default)s]')
parser.add_argument('--date', '-d', default=None, metavar='WHEN',
help='target date for the meeting, supports arbitrary dates like "in two weeks" [default: now]')
parser.add_argument('--colors', '--no-colors', action=NegateAction, default=sys.stdout.isatty(),
parser.add_argument('--colors', '--no-colors', action=NegateAction,
default=sys.stdout.isatty() and 'NO_COLOR' not in os.environ,
help='show colors [default: %(default)s]')
parser.add_argument('--default-zone', '--no-default-zone', action=NegateAction,
help='show current timezone first [default: %(default)s]')
......@@ -101,6 +101,11 @@ Show a longer work day in march 2014.
Default timezone.
If this environment variable is defined, no color will be shown unless
the \-\-colors flag is passed. Comforming to
.URL "NO_COLOR informal standard"
.BR tzselect(8)
.BR tzfile(5)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment