#4 Do not (always) use colors
Closed: Fixed None Opened 12 years ago by psabata.

packagedb-cli always uses colors in its output. This might be an issue for some terminals or for automatic output processing.

Please, do not use colors in non-interactive sessions and/or allow your users to turn this feature on and off.


I only used a red color as I thought it is unlikely that someone uses a red background for his terminal.

Would an option --nocolor be acceptable ?

Replying to [comment:1 pingou]:

I only used a red color as I thought it is unlikely that someone uses a red background for his terminal.

That's not exactly what I meant. Try redirecting the output to a file and see what's in there :)

Would an option --nocolor be acceptable ?

Yes, it would.

Checking for terminal capabilities would also be nice.

Replying to [comment:4 psabata]:

Checking for terminal capabilities would also be nice.

Sorry for asking, but would you have a link on this?

Replying to [comment:5 pingou]:

Replying to [comment:4 psabata]:

Checking for terminal capabilities would also be nice.

Sorry for asking, but would you have a link on this?

Not really. I don't know much about Python to help you with that. Maybe there are some terminfo bindings? Or maybe it's a part of curses modules?

http://en.wikipedia.org/wiki/Terminfo

Replying to [comment:7 pingou]:

Ok I pushed the attached patch in https://fedorahosted.org/packagedb-cli/browser/pkgdb.py?rev=d9a787912bf42d877a129fb3f712a2d4f1b4c671

Thanks, this doesn't actually solve the issue, though.

Could that option also remove the bold style?

{{{
$ ./pkgdb.py --nocolor acl perl-BerkeleyDB
Fedora Package Database -- perl-BerkeleyDB
Perl extension for Berkeley DB version 2, 3 or 4
0 bugs open (new, assigned, needinfo)
^[[0;0m^[[1mdevel^[[0;0m Owner: steve
watchbugzilla watchcommits commit approveacls
Group:
packager Obsolete
provenpackager Approved
Comaintainer(s):
perl-sig Approved Approved
Last build: 2011-02-08 by ausil for perl-BerkeleyDB-0.43-5.fc15 in dist-rawhide
}}}

Replying to [comment:9 pingou]:

I figured that out and the following commit put things in the right way:
https://fedorahosted.org/packagedb-cli/changeset/691cbd4a9507653267a04593e69f8a7706e947ba

I don't get the indentation now but okay :)

Replying to [comment:10 psabata]:

I don't get the indentation now but okay :)

That's weird. I have the indentation here:

{{{
$ python pkgdb.py --nocolor acl guake > out
$ cat out
Fedora Package Database -- guake
Drop-down terminal for GNOME
5 bugs open (new, assigned, needinfo)
devel Owner: pingou
watchbugzilla watchcommits commit approveacls
Group:
packager Obsolete
provenpackager Approved
Comaintainer(s):
maxamillion Approved Approved
Last build: 2011-02-09 by ausil for guake-0.4.2-3.fc15 in dist-rawhide
}}}

I mean I don't understand why it's there.

If I use colors (default), "devel" word starts in the first column. It's not the case with --nocolor, though. Why is that?

I was not looking at the right place, fixed in: https://fedorahosted.org/packagedb-cli/changeset/e0fcee04db6843d71f18260e6b8251c5c20be29e

Sorry for the confusion and thanks for the report

Login to comment on this ticket.

Metadata