Skip to content

Commit

Permalink
Respect the NO_COLOR environment variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins committed Jul 27, 2018
1 parent 4a544fe commit 04ea123
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bikeshed/cli.py
Expand Up @@ -28,8 +28,8 @@ def main():
help="Force the preprocessor to run to completion; fatal errors don't stop processing.")
argparser.add_argument("-d", "--dry-run", dest="dryRun", action="store_true",
help="Prevents the processor from actually saving anything to disk, but otherwise fully runs.")
argparser.add_argument("--print", dest="printMode", action="store", default="console",
help="Print mode. Options are 'plain' (just text), 'console' (colored with console color codes), 'markup', and 'json'.")
argparser.add_argument("--print", dest="printMode", action="store", default=None,
help="Print mode. Options are 'plain' (just text), 'console' (colored with console color codes), 'markup', and 'json'. Defaults to 'console'.")

subparsers = argparser.add_subparsers(title="Subcommands", dest='subparserName')

Expand Down Expand Up @@ -190,7 +190,13 @@ def main():
config.quiet = float("infinity")
config.force = options.force
config.dryRun = options.dryRun
config.printMode = options.printMode
if options.printMode is None:
if "NO_COLOR" in os.environ:
config.printMode = "plain"
else:
config.printMode = "console"
else:
config.printMode = options.printMode

update.fixupDataFiles()
if options.subparserName == "update":
Expand Down

0 comments on commit 04ea123

Please sign in to comment.