2 ms·
I was saying that Accept Headers or "format negotiation" concepts that are typically used in client-server communications are a bit overkill for command line to
by thesuperbigfrog 4y ago
I was saying that Accept Headers or "format negotiation" concepts that are typically used in client-server communications are a bit overkill for command line tools and shell pipelines.
I agree that human-readable text formats should be the default output formats for command line tools, but that easy-to-parse structured text output formats should be easy to specify with either environment variables or command line flags.
If I am writing a script and I am using tools that support a given structured output format and use environment variables or command line flags for output configuration it could work something like this:
#!/bin/env script-interpreter
export PREFERRED_OUTPUT_FORMAT="JSON"
query-cli-tool | filter-cli-tool --output-format=json | combinator-cli-tool --input-format=json | pretty-formatter-tool > output_file
This would mean that the command line tools default to human-readable formats, but can still generate JSON or some other structured text format when configured to do so.