> How do you test CLI?<p>I do not understand this. Has the author used <i>diff</i> or stdin/stdout redirection? Testing CLI is trivial in comparison to testing a GUI or another kind of interface; it is all text and so can easily be compared against a correct result. CLIs are not meant for every task, but one of their core advantages is ease of automation and testing.
Strong disagree.<p>Any system worth keeping around should be a library (or family of libraries) which have a CLI fronting it that serves to pass parameters to it just as you might any other way (such as through some other program or REST API or GUI). Agree the CLI "shell" around the system should not have separate logic, but should report back logic faults from within the library.
I <i>think</i> this is trying to say you shouldn't build CLI parsing logic into your core functionality, and this makes sense.<p>Core functionality should be in functions, classes, etc. and a CLI utility can be separately written or synthesized that imports that library, and anything wanting to implement a different interface can do the same.<p>Isn't that the way it's normally done? Real world example is libcurl and curl command.
This... isn't persuasive. I'm genuinely struggling to find a deeper critique than that.<p>Perhaps if there were examples of all the confident statements? But they're just terse declarative sentences, all I could say is "nuh uh!"
I read the core argument as:<p>Don't write a shell CLI prematurely - a script in whatever language you're using can often be just as good a interface. Maintaining a shell CLI is work.<p>If you write a shell CLI don't aim for full flexibility - a script already fulfill that role.<p>I'm a big fan of shell CLIs (command --option=1), but I think this way of thinking has merit. I would consider a script a subset of CLIs though, using a python REPL with preloaded modules is certainly a type of CLI, no? Code is a sequence of commands.<p>That being said, as the author mentions, new libaries make it really easy to expose some functions to a shell CLI. If the task mesh well with piping, exposing some primitive to the shell is probably worth it.