Writing good CLI apps - Programming On Unix

Users browsing this thread: 3 Guest(s)
venam
Administrators
As I said in the newsletter, this is sort of the current "hype" of writing cli tools, with ton of prettifier and helpers, and that doesn't follow any of the usual conventions or good practices for writing good cli programs.

(12-10-2018, 01:52 PM)z3bra Wrote: There is this point about the "help" feature of your apps, saying that you should offer multiple ways to display the help:
app
app -h
app --help
app help

Any library that you include to parse command line arguments the standard way won't have that last option and won't show any help on the first option if no arguments are mandatory. That's how much bad practice this is.

(12-10-2018, 07:12 PM)z3bra Wrote: As I see it, --help should only be a reminder for the syntax and available flags.
For example, you would use --help when I'm not sure if the flag to make chmod do recursion is -r or -R.
--help should be clean and easy to read. The detailed usage goes to the manual.

I can't agree more with that one. The help that span on more than a screen size bother me the most because you have to pass them in a pager, so then you're better off reading a manpage.

Maybe I should mention something that has not been said yet. I'm all in with colors for command line tools but they should be disabled by default. Maybe the tool should follow that $NO_COLOR environment too.

As for all the good practices I think we discussed that topic a lot in other places too: https://nixers.net/showthread.php?tid=1893
Some good links that were in that entry of the newsletter that are good to mention are:
http://julio.meroh.net/2013/09/cli-desig...ap-up.html
https://monkey.org/~marius/unix-tools-hints.html
http://www.catb.org/~esr/writings/taoup/html/


Messages In This Thread
Writing good CLI apps - by z3bra - 12-10-2018, 01:52 PM
RE: Writing good CLI apps - by jkl - 12-10-2018, 03:11 PM
RE: Writing good CLI apps - by z3bra - 12-10-2018, 04:38 PM
RE: Writing good CLI apps - by mrnd - 12-10-2018, 05:36 PM
RE: Writing good CLI apps - by z3bra - 12-10-2018, 07:12 PM
RE: Writing good CLI apps - by venam - 13-10-2018, 03:14 AM