3 ms·
Or just pipe the output into a filter that outputs the json for you.
by rcfox 14y ago
Or just pipe the output into a filter that outputs the json for you.
- bandy 14y agoThere's no Job Security in that! You need to rearchitect the entire system to add in protocol support for the flavor-of-the-moment each time it changes.
- renownedmedia 14y agoThe article uses JSON as an example, and goes on to say that any data exchange format would work. XML could become the standard as it is easily converted into different data storage languages without the need to write output specific filters.
- jamesbritt 14y agoExactly. 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.
- renownedmedia 14y agoThat would require an externally located filter which changes each time the output changes.
- rcfox 14y agoThe "What if the output changes?" argument doesn't hold water in my books. If the command supported JSON internally, then it can still change its JSON output. Either way, you have to handle it. If you're managing the filter yourself, then you can handle the change in the program's output while keeping the output of the filter unchanged. Now, which is going to be easier to test with a new input scheme: the filter that only does one thing, or your program?
- renownedmedia 14y agoA filter is an added level of processing and complexity. Why take data being used in the app, convert it into a human readable format, just to have it parsed with regex and made readable by another 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.