Updated Branches: refs/heads/cassandra-1.1 aba5a3765 -> 7cbc0be23
cqlsh: allow disabling colors. Patch by Tyler Hobbs, reviewed by brandonwilliams for CASSANDRA-4634 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7cbc0be2 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7cbc0be2 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7cbc0be2 Branch: refs/heads/cassandra-1.1 Commit: 7cbc0be23d258559aa823cd9fa8586ff81f71c91 Parents: aba5a37 Author: Brandon Williams <[email protected]> Authored: Mon Sep 10 14:40:45 2012 -0500 Committer: Brandon Williams <[email protected]> Committed: Mon Sep 10 14:41:43 2012 -0500 ---------------------------------------------------------------------- bin/cqlsh | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/7cbc0be2/bin/cqlsh ---------------------------------------------------------------------- diff --git a/bin/cqlsh b/bin/cqlsh index 6b61364..8d98c28 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -121,8 +121,10 @@ precedence over any defaults.""" % globals() parser = optparse.OptionParser(description=description, epilog=epilog, usage="Usage: %prog [options] [host [port]]", version='cqlsh ' + version) -parser.add_option("-C", "--color", action="store_true", - help="Enable color output.") +parser.add_option("-C", "--color", action='store_true', dest='color', + help='Always use color output') +parser.add_option("--no-color", action='store_false', dest='color', + help='Never use color output') parser.add_option("-u", "--username", help="Authenticate as user.") parser.add_option("-p", "--password", help="Authenticate using password.") parser.add_option('-k', '--keyspace', help='Authenticate to the given keyspace.') @@ -2598,9 +2600,6 @@ def read_options(cmdlineargs, environment): optvalues.keyspace = option_with_default(configs.get, 'authentication', 'keyspace') optvalues.completekey = option_with_default(configs.get, 'ui', 'completekey', 'tab') optvalues.color = option_with_default(configs.getboolean, 'ui', 'color') - if optvalues.color is None: - # default yes if tty - optvalues.color = should_use_color() optvalues.debug = False optvalues.file = None optvalues.tty = sys.stdin.isatty() @@ -2620,9 +2619,16 @@ def read_options(cmdlineargs, environment): port = arguments[1] if options.file is not None: - options.color = False options.tty = False + if optvalues.color in (True, False): + options.color = optvalues.color + else: + if options.file is not None: + options.color = False + else: + options.color = should_use_color() + options.cqlversion, cqlvertup = full_cql_version(options.cqlversion) if cqlvertup[0] < 3: options.cqlmodule = cqlhandling
