*nix command line apps should have a –json output flag
thomashunter.name
thomashunter.name
It seems people want to wrap things and parse them rather than making the same basic library calls themselves. Note the "inspiration" part of this post: the author started parsing the output of iwlist instead of just making the requisite calls directly.
Oh, and don't derail this with a discussion of suid-ness required for raw sockets (ping) or whatever magic ioctls that an iwlist-alike would require. This applies to other things which can run as a normal user, too.
Also, I write a lot of apps which I release under the BSD license, and generally shy away from touching anyone else's binary libraries for fear of catching the GPL.
Now I have a question: Are there such things as shell meta commands?
For example, if I try to run some CLI thing called `foo`, the shell (or a shell wrapper) first looks to see if the complete invocation has an argument `--json` and if so converts the actually executed command to
foo | some-json-formatter "foo"
Basically, can a shell rewrite a command-line call, and how hackable is this?If so then one could write a script that catalogs assorted other CLI apps and runs a formatter for the things it knows about, avoiding having to add yet another feature to countless existing CLI programs.
Now, which is going to be easier to test with a new input scheme: the filter that only does one thing, or your program?
Now, which is going to be more convenient: Rewrite a regular expression or grab a different data node? Personally I would rather have the data format change than have rebuild a complex parser.