diff --git a/client/equo.py b/client/equo.py index 996bdfd23..6f2fceb35 100644 --- a/client/equo.py +++ b/client/equo.py @@ -55,10 +55,6 @@ etp_exit_messages = { 7: _("Go to hell."), } -# Check if we need to disable colors -if not is_stdout_a_tty(): - nocolor() - help_opts = [ None, (0, " ~ %s ~ " % ("equo",), 2, @@ -69,6 +65,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')), (1, '--bashcomp', 1, _('print a bash completion script to stdout')), None, (0, _('Application Options'), 0, None), @@ -773,9 +770,12 @@ for n in range(len(options)): options.extend(x_found_opts) bashcomp_enabled = False +force_color = False for opt in options: if opt in ["--nocolor", "-N"]: nocolor() + elif opt in ["--color", "-C"]: + force_color = True elif opt == "--debug": continue elif opt in ["--quiet", "-q"]: @@ -796,6 +796,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() + if bashcomp_enabled: print_bashcomp(help_opts + help_opts_extended, options, BASHCOMP_MAP) raise SystemExit(0) diff --git a/docs/man/equo.pod b/docs/man/equo.pod index 43809191a..66b7c2cc0 100644 --- a/docs/man/equo.pod +++ b/docs/man/equo.pod @@ -47,6 +47,10 @@ print version disable colorized output +=item B<--color> + +force colorized output + =item [1] B<--bashcomp> print a bash completion script to stdout diff --git a/docs/man/man1/equo.1 b/docs/man/man1/equo.1 index bbf55da34..c00cf1ba3 100644 --- a/docs/man/man1/equo.1 +++ b/docs/man/man1/equo.1 @@ -123,8 +123,8 @@ .rm #[ #] #H #V #F C .\" ======================================================================== .\" -.IX Title "A 1" -.TH A 1 "2011-04-05" "perl v5.12.2" "User Contributed Perl Documentation" +.IX Title "EQUO 1" +.TH EQUO 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 @@ -168,6 +168,9 @@ print version .IP "[1] \fB\-\-nocolor\fR" 4 .IX Item "[1] --nocolor" disable colorized output +.IP "\fB\-\-color\fR" 4 +.IX Item "--color" +force colorized output .IP "[1] \fB\-\-bashcomp\fR" 4 .IX Item "[1] --bashcomp" print a bash completion script to stdout