You are not logged in.

#1 2016-09-10 14:45:09

thePhysicist8
Member
Registered: 2015-06-25
Posts: 17

Why don't more programs have colorized --help output?

Man pages have bold and underlined text to improve clarity, and with some tweaking this can be turned into colored text. Programs' --help messages are obviously limited to plain-text, but they can still use colors to distinguish things like command-line options and arguments. This thought never really occurred to me until I noticed that the --help output for the keychain command was colorized. Why don't more programs do this? It's not like people are still using terminals that don't support color.

Offline

#2 2016-09-10 15:11:48

mpan
Member
Registered: 2012-08-01
Posts: 1,206
Website

Re: Why don't more programs have colorized --help output?

Most probably because it requires much more coding and maintenance to have formatted output than simply send raw, hardcoded text.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#3 2016-09-10 15:35:27

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Why don't more programs have colorized --help output?

Laziness, sheer laziness. Plus they'll get people moaning about the colorscheme wink

Offline

#4 2016-09-10 19:51:09

thePhysicist8
Member
Registered: 2015-06-25
Posts: 17

Re: Why don't more programs have colorized --help output?

Printing the contents of a here doc with colors in bash is pretty easy using tput. Is it really that much more challenging in other languages? Yes, editing the text becomes a bit annoying, but given the amount of effort people put into their programs, I can't imagine that they'd get hung up over a couple dozen lines of text.

I'm really just struck by the fact that keychain is the only program I've ever seen with a colorized --help output.

Offline

#5 2016-09-10 20:10:00

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Why don't more programs have colorized --help output?

It's bloat. The effort required to produce coloured output is disproportionate to any benefit.

If you feel strongly about it, write some patches; that is the ultimate proof of its purported utility.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2016-09-10 20:22:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Why don't more programs have colorized --help output?

Also note, man pages do not have color.  Full stop.

Man pages have a standardized format.  And some man page readers will take advantage of elements of that format to colorize some bits if you set up your man page reader to do so.

There is absolutely nothing stoping you from writing a --help-reader that colorizes the output of a --help flag.  This is limited by the degree to which there is a standardized format for help output, but there are certainly some common conventions.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2016-09-10 22:00:16

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: Why don't more programs have colorized --help output?

thanks to this thread, I discovered https://wiki.archlinux.org/index.php/Co … onsole#man
mind=blown.

Offline

#8 2016-09-10 22:33:54

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Why don't more programs have colorized --help output?

HiImTye, wait till you discover vimpager.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2016-09-11 00:19:49

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: Why don't more programs have colorized --help output?

yikes
that looks so much better.

more specifically, it doesn't have formatting errors like the other way

Last edited by HiImTye (2016-09-11 00:22:09)

Offline

#10 2016-09-11 00:51:19

thePhysicist8
Member
Registered: 2015-06-25
Posts: 17

Re: Why don't more programs have colorized --help output?

Trilby wrote:

Also note, man pages do not have color.  Full stop.

Man pages have a standardized format.  And some man page readers will take advantage of elements of that format to colorize some bits if you set up your man page reader to do so.

There is absolutely nothing stoping you from writing a --help-reader that colorizes the output of a --help flag.  This is limited by the degree to which there is a standardized format for help output, but there are certainly some common conventions.

I wasn't trying to imply that the color comes from groff, but I can see how my post was poorly-worded. Thank you for clarifying.

Also, I want to mention that I'm not complaining about the lack of colorized --help pages. I really just wanted to try incorporating them into my own scripts, and was wondering if there was a good reason not to.

Last edited by thePhysicist8 (2016-09-11 00:57:56)

Offline

#11 2016-09-11 07:34:56

mpan
Member
Registered: 2012-08-01
Posts: 1,206
Website

Re: Why don't more programs have colorized --help output?

thePhysicist8 wrote:

Printing the contents of a here doc with colors in bash is pretty easy using tput.

How well your “tput in heredoc” solution works when one redirects the output to a non-terminal consumer? How well it works on Windows? Of course you also introduce an argument parsing tool capable of handling long options, into each your program, because if you allow colorified output you also need to let the user opt out with something like --color=never; and you also handle that properly. Right? Then you also teach each of your translators how to properly use your solution — since, you know, many people involved in translating libre software have zero knowledge on programming. And then each translation can’t be considered data, but executable code, so you do follow the best security guidelines on accepting contributions… is that so? Shall I continue?

You see… there is a small difference between writing a simple script for yourself and doing fancy stuff for fun, and maintaining software used by millions of people. Especially when there is not enough resources in the community and they can be spent on more valuable tasks.

Last edited by mpan (2016-09-11 07:39:07)


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#12 2016-09-11 14:07:07

thePhysicist8
Member
Registered: 2015-06-25
Posts: 17

Re: Why don't more programs have colorized --help output?

Thanks mpan, you bring up some good points that I hadn't considered before. I'm starting to get the picture.

A quick question: Regarding the first point you brought up, could that problem not be avoided by doing something like this?

if [[ -t 1 ]]; then
    cB="$(tput bold)"
    cN="$(tput sgr0)"
fi

cat <<-EOF
    ${cB}Foobar${cN}
EOF

Offline

#13 2016-09-11 14:26:06

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Why don't more programs have colorized --help output?

Another difference between keychain's --help output and that of many other programs is the length of the descriptions.

Most programs use a table-like overview of options with one or at most a few lines to describe each option (good enough to check the exact name of an option, for example) and the man page provides more detail (better for unfamiliar programs or rarely used options).

Keychain seems to output the complete text from the man page (without general description and examples) and this means that just like the man page, it benefits more from some special formatting.

Offline

#14 2016-09-11 16:29:19

mpan
Member
Registered: 2012-08-01
Posts: 1,206
Website

Re: Why don't more programs have colorized --help output?

thePhysicist8 wrote:

Thanks mpan, you bring up some good points that I hadn't considered before. I'm starting to get the picture.

Just as a quick “one picture is worth a thousand words”, this is what `keychain --help | less` produces on my system¹.

thePhysicist8 wrote:

A quick question: Regarding the first point you brought up, could that problem not be avoided by doing something like this?

Yes, surely! I was not saying that it’s impossible to solve the issue — it’s just a PITA and unnecessary waste of resources.
____
¹ Yes, I know less can be configured to pass raw escape sequences, but it’s not the default.

Last edited by mpan (2016-09-11 16:30:33)


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#15 2016-10-07 10:24:08

cirrus
Member
From: Glasgow Scotland
Registered: 2012-08-24
Posts: 340
Website

Re: Why don't more programs have colorized --help output?

OP packages such as ccze & cw will add a wee bit of colour to your life.

Last edited by cirrus (2016-10-07 10:29:31)

Offline

Board footer

Powered by FluxBB