From ffb7c9dd17f9cf26afb356c1bd9359ebfefe4bff Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Fri, 29 Apr 2011 17:13:27 +0200 Subject: [PATCH] [activator] add --color option, see bug #2381 --- docs/man/activator.pod | 4 ++++ docs/man/man1/activator.1 | 9 ++++++--- server/activator.py | 14 +++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/docs/man/activator.pod b/docs/man/activator.pod index 0e34e5bad..7af87a07b 100644 --- a/docs/man/activator.pod +++ b/docs/man/activator.pod @@ -33,6 +33,10 @@ print version disable colorized output +=item B<--color> + +force colorized output + =back =head1 OPTIONS diff --git a/docs/man/man1/activator.1 b/docs/man/man1/activator.1 index cdde879f1..bd2453102 100644 --- a/docs/man/man1/activator.1 +++ b/docs/man/man1/activator.1 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "ACTIVATOR 1" -.TH ACTIVATOR 1 "2011-02-07" "perl v5.12.2" "Entropy" +.TH ACTIVATOR 1 "2011-04-29" "perl v5.12.2" "Entropy" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -155,6 +155,9 @@ print version .IP "\fB\-\-nocolor\fR" 4 .IX Item "--nocolor" disable colorized output +.IP "\fB\-\-color\fR" 4 +.IX Item "--color" +force colorized output .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fBsync\fR" 4 @@ -282,6 +285,6 @@ Fabio Erculiani .SH "POD ERRORS" .IX Header "POD ERRORS" Hey! \fBThe above document had some coding errors, which are explained below:\fR -.IP "Around line 184:" 4 -.IX Item "Around line 184:" +.IP "Around line 188:" 4 +.IX Item "Around line 188:" You forgot a '=back' before '=head1' diff --git a/server/activator.py b/server/activator.py index 6bd4cb3fe..b58a85615 100644 --- a/server/activator.py +++ b/server/activator.py @@ -29,10 +29,6 @@ from text_tools import print_menu def get_entropy_server(): return Server(community_repo = etpConst['community']['mode']) -# Check if we need to disable colors -if not is_stdout_a_tty(): - nocolor() - help_opts = [ None, (0, " ~ activator ~ ", 1, @@ -43,6 +39,7 @@ help_opts = [ (1, '--help', 2, _('this output')), (1, '--version', 1, _('print version')), (1, '--nocolor', 1, _('disable colorized output')), + (1, '--color', 2, _('force colorized output')), None, (0, _('Application Options'), 0, None), None, @@ -113,9 +110,12 @@ for n in range(len(options)): # preliminary options parsing _options = [] +force_color = False for opt in options: - if opt == "--nocolor": + if opt in ["--nocolor", "-N"]: nocolor() + elif opt in ["--color", "-C"]: + force_color = True elif opt in ["--quiet", "-q"]: etpUi['quiet'] = True elif opt in ["--verbose", "-v"]: @@ -128,6 +128,10 @@ for opt in options: _options.append(opt) options = _options +# Check if we need to disable colors +if (not force_color) and (not is_stdout_a_tty()): + nocolor() + # print help if not options or ("--help" in options) or ("-h" in options): print_menu(help_opts)