Command Line Interface Guidelines

clig.dev

163 points by subset 5 days ago


eikenberry - a day ago

> Use a pager (e.g. less) if you are outputting a lot of text.

If I wanted to use a pager I'd pipe the output to a pager, no pipe to pager means I want it all dumped to STDOUT. So annoying.

Grom_PE - a day ago

For comfortable reading, I just had to figure out what on this webpage causes Chromium to drop subpixel rendering, and it's not this:

    html { -webkit-font-smoothing: antialiased; }
it's this:

    #TableOfContents { backdrop-filter: blur(3px); }
A panel that overlaps content only on narrow screens disables subpixel rendering for the entire text. Thanks Chromium. Not an issue on Firefox, btw.
hankbond - a day ago

> Whatever software you’re building, you can be absolutely certain that people will use it in ways you didn’t anticipate. Your software will become a part in a larger system—your only choice is over whether it will be a well-behaved part.

good advice

inetknght - a day ago

Previous discussions:

- (2024): https://news.ycombinator.com/item?id=39273932

- (2020): https://news.ycombinator.com/item?id=25304257

jklowden - 13 hours ago

Geez, what a lot of vague self-contradictory self-regarding opinionated advice.

Is terminal a world of “pure information’ or “a mess”? Both, it seems. Don’t dump “pages and pages of debug” text? Check. But do use boldface fonts “in a terminal independent way” and “try” to provide man pages. But because “some people” don’t know about them and “some platforms” don’t support them, provide help text by default.

Those “some” by the way are one: Windows. Do please enlighten us on the terminal-independent font control system that includes CMD.EXE.

How much is too much? Their showcase examples are more than 25 lines, more than the default size of a terminal window. The authors don’t give much weight to context, to the ability to look back on over the history of the interactive session. No, much better to splat the screen with 50 lines the user didn’t request, because helpful.

Oh, and don’t write a filter like cat(1). How the system is supposed to distinguish between reading from standard input and reading from standard input by mistake, they don’t say. Just quit and print a help message.

I have different advice: please don’t help. Please be quiet. Don’t suggest, don’t guess, dont offer, don’t assume. Just do. Do what the user said. If he wants something else, he’ll say so in time.

If you want —help to do something useful because you think your user is too dense to find the manual (condescension much?) then invoke it for him. Just maybe put a hint somewhere to press “q” to quit.

Virtually all the “help” I get on the command line is unasked-for and unwanted and unhelpful. If I fat-finger “ls”, I don’t need a suggestion to install lsof. The very last thing I want is 50 lines of noise obscuring what I was looking at before you so helpfully interrupted.

roundabout-host - 12 hours ago

    Display output on success, but keep it brief. Traditionally, when nothing is wrong, UNIX commands display no output to the user. This makes sense when they’re being used in scripts, but can make commands appear to be hanging or broken when used by humans. For example, cp will not print anything, even if it takes a long time.
It starts with talking about no indication of success, then switches to no indication of progress. I think they are pretty different.

Also, what kind of "responsive" font sizing does this website have?

kazinator - a day ago

> A command is saying too little when it hangs for several minutes and the user starts to wonder if it’s broken.

Nope. For debugging the program, it is nice to have some debug tracing option, but if it's not the program's specification to produce output, it should not produce any. If the program's specification is that it produces a certain output after a certain calculation, then it shall not produce any other output, even if that calculation takes three weeks.

"cp -r from to" is supposed to be quiet until it's done or hits an error.

It would be nice to have an agreed-upon protocol for progress reporting. For instance, imagine of we had file descriptor 3 as "stdprogress". Programs could dump specially formatted messages there which the parent job control shell could intercept and turn into a progress display (with multiple rows for pipeline elements and such). It's not bad; but fluff like this can't be in band with the output, or at least not by default.

atiedebee - 20 hours ago

> The concise help text should only include:

> - A description of what your program does.

> - One or two example invocations.

> - Descriptions of flags, unless there are lots of them.

> - An instruction to pass the --help flag for more information.

I disagree with this. The first 3 points should all unconditionally be in the man page of the program. In my ideal scenario, the jq short help message would omit everything after the "Usage" section except for the message to run the command with --help.

kps - 13 hours ago

Colour addendum: If the user hasn't configured anything, don't use a colour other than red without checking whether the terminal has a light or dark background. Don't hardcode colours.

ljwolf - 16 hours ago

Why is this high x-height serif-based typography taking over SF aesthetics now?

esalman - a day ago

I have used click/typer packages to build some python-based CLI programs. It's easy and user-friendly way to build, but the amount of time it takes for python to start the environment followed by the actual program to do anything is annoying.