Live data from Hacker News

12 Factor CLI Apps

medium.com

121–130 of 253 posts

Re: 12 Factor CLI Apps

#121
> 7. Prompt if you can

Please don't. There is nothing wrong with interactive tools, but by default, they should not be. So instead of making non-interactive session possible via flags, the default should be to be non-interactive. If there is an option to start an interactive session, everything is fine.

Otherwise, you would never know when your script could run into some kind of interactive session (and therefore break; possibly after an update).

Re: 12 Factor CLI Apps

#122
post #42

> 12. Follow XDG-spec I'm so glad to see this included. I don't like $HOME being cluttered with . config directories, but worse than that, far too many when releasing on macOS say Oh Library/Application\ Support/ /vom/something is the standard config location on Mac, so I'll respect XDG on Linux but on Mac it should go there. No! Such an unfriendly location for editable config files.

I agree that seeing a bunch of ~/. directories is annoying, but at the same time I do think that it makes sense for each application to manage its own hierarchy, rooted under e.g. ~/.apps/ instead of splitting it into ~/.config/ , ~/.local/share/ , etc. Regardless, I think it probably makes sense to have a uniform interface for getting said directories, so that however the OS decides things should be laid out, the de…

The reason ~/.config/app is superior, is that then you can e.g. backup all your configs, or remove your cache, or store ~/.local and ~/.cache on a local fs and the rest of ~ on NFS.

Do you have to use ~/.config/app/ or could you just use ~/.config/app.conf?

Re: 12 Factor CLI Apps

#123

Don't get me wrong! I love command line apps. But I wonder if we all have a bit of an Stockholm syndrome... there are several things that suck about them... While writing this I'm thinking on my experience trying to do anything with ffmpeg or imagemagick... or even find. * For any sufficiently complicated cmd line app, the list of arguments can be huge and the --help so terse as to be become useless. For man pages, t…

> Sometimes I end up passing the help output through grep, then copy-pasting the flags from the output, and then hoping I got the right flag. man x | grep -P y -C 3 | less ...is my standard here (-C 3 includes the pre- and succeeding 3 lines). For all the delights of CLIs, man pages are by default opaque walls of text. And dear lord the number of regex variants... - at this point, if at all possible, I'll avoid appli…

If you're already piping to less, just use its search functionality; type '/', the regexp, and then enter.

Re: 12 Factor CLI Apps

#124
post #84
post #83

Unless you already know your users will want man pages, I wouldn’t bother also outputting them as they just aren’t used often enough anymore. I don't know where this is coming from, me and my colleagues are reading man pages every day. I would be interested how much others read them.

I strongly disagree on this one too. That's the first place I look for help and it annoys me to no end when a CLI program that doesn't come with one. I stopped taking seriously the article at that point and quickly skimmed through the rest of it. Man pages are a great unix culture heritage, please new developers don't give up on them!

Moreover, man pages serve as an essential resource that is much more reliably available than any other - when my network's routing packets in circles, the database server's on fire, and the duplicate has repeated the last transaction on every record, I don't care how "most users" don't use man pages or that web documentation is much more Google-able; I care that I have access to complete, detailed information (not the abbreviated version provided by --help) on all the utilities available to me; I care that apropos can help me recall the names of utilities I don't remember (something the article does not address); I care that I don't have to worry about having access to documentation, in addition to everything else, because it's all in a single, standardized, effective repository of man pages.

I really can't express strongly enough how much I disagree with the view that man pages are no longer relevant or necessary.

Re: 12 Factor CLI Apps

#125
post #120

I don't agree with 7 and 8. I like silent apps while working, and actually I'm used to applications saying nothing if everything is correct. Also, "outputting something to stdout just because I can" kills scriptability a lot. Using tables, colors and other stuff requires a lot of terminal support. MacOS terminal, iTerm, Linux terminals supports a lot of stuff, but not always (our team is generally using XTerm for exa…

You can just have a "quiet" mode for scripting. Or even better, detect if you're connected to a TTY.

Checking whether you're connected to a TTY is a good practice, but there's also cognitive advantages of silent applications too.

Also, similarly you can have a -v --verbose set to make the application talkative. It's also an option.

Re: 12 Factor CLI Apps

#126
post #83

Unless you already know your users will want man pages, I wouldn’t bother also outputting them as they just aren’t used often enough anymore. I don't know where this is coming from, me and my colleagues are reading man pages every day. I would be interested how much others read them.

man pages are the first place I'm looking in for flags for commands I know for years, or when I'm using new commands — and it's always a frustrating experience when they don't exist.

Please, always ship man pages with whatever you write. It's /easy/ to do and has a great added value.

PS: doc on the web is so often irrelevant… either too old, or too recent — and in the rare cases where it's properly versioned, the workflow is something like “cmd --version ; google cmd $version” instead of just “man cmd”, which is nowhere as convenient or reliable.

Re: 12 Factor CLI Apps

#127

Earlier quoted context omitted.

> Sometimes I end up passing the help output through grep, then copy-pasting the flags from the output, and then hoping I got the right flag. man x | grep -P y -C 3 | less ...is my standard here (-C 3 includes the pre- and succeeding 3 lines). For all the delights of CLIs, man pages are by default opaque walls of text. And dear lord the number of regex variants... - at this point, if at all possible, I'll avoid appli…

If you're already piping to less, just use its search functionality; type '/', the regexp, and then enter.

For that, you might as well just use the regex functionality in man itself too. But that misses the point.

The goal of grepping in that snippet is that you're `less `ing through precisely the parts that matter, and no more, rather than wading through the whole man page, and you're using -C to control how much context you (think you) need around the search results. This is a much better setup for skimming through potential hits than going through the man page wall of text.

Re: 12 Factor CLI Apps

#128

Earlier quoted context omitted.

Powershell made 2 things gospel and I'm just sad it's going to take 20 years for other operating systems to realize that's the way to do it and something that replaces linux to see it in practice (i.e. it just won't) 1. Auto-complete is by-design part of the language/shell 1. Pre-approved Verb list that prefix commands helps discoverability and usability no end. Still learning? Get- will literally never cause a probl…

I never really found the verb list to be entirely satisfactory. It's great that they gave boundaries but I find it too verbose. There are other kinds of syntactic ergonomics with concise vocabulary (lisp has ! xxx p$ for instance, they're a bit harder to swallow but I find the code a bit more poetic and easier to remember as a pattern). About the objects vs strings, Kalman Reti (of Symbolics IIRC) talked [1] about ho…

The verb list is, in practice, 90% Get-* and Set-* , so for most users that will cover the case where they need to read and modify some system state in a script.

It may not cover your particular use case (I want to foo this bar), but as restriction on the language it helps your users not have to discover esoteric commands.

Re: 12 Factor CLI Apps

#129

Earlier quoted context omitted.

> Sometimes I end up passing the help output through grep, then copy-pasting the flags from the output, and then hoping I got the right flag. man x | grep -P y -C 3 | less ...is my standard here (-C 3 includes the pre- and succeeding 3 lines). For all the delights of CLIs, man pages are by default opaque walls of text. And dear lord the number of regex variants... - at this point, if at all possible, I'll avoid appli…

If you're already piping to less, just use its search functionality; type '/', the regexp, and then enter.

You can also do that directly in 'man'.

Re: 12 Factor CLI Apps

#130
...all of these must show help.

  $ mycli
Some commands have an unambiguous meaning and don't need arguments. For example, it would be weird if a bare "make" command returned help information. Great post, though. I'm looking forward to digging into oclif.
Post reply on HN