I'm writing a set of "Unix Way" tools, where you have a set of small tools that you can pipe into each other (and other tools).
The question (more details as to why I care below) is this: Is there a recommended output format for tabular format for command line output, that's convenient to columnize and consume by other standard Unix tools?
I'm writing a set of tools to manage and search sets of Magic the Gathering cards on the command line. I'm trying make the tools laser focused, each doing exactly one job.
I have a tool named mtg-identify-set, which takes as a parameter the name of set, and then does a fuzzy search on set names, dumping out a list of matches from best to worst:
The output for searching for "Theros" is the following:
- ths, "theros", 100.00
- tths, "theros tokens", 63.15789473684200
- pths, "theros promos", 63.15789473684200
- drk, "the dark", 57.14285714285700
- aer, "aether revolt", 52.63157894736800
So it's outputting the set code, the set name, and a percentage match ignoring capital letters.
I'm trying to write these tools the "cat -v considered harmful" way (http://harmful.cat-v.org/cat-v/), without formatting parameters, trying to keep the tools to "one job".
But that's lead me to a problem... how should the output actually be sent to the command line? Unix tools themselves are very inconsistent, and in this day and age the actual toolkit programs we have do wildly weird things to output in a completely inconsistent manner. Most have their own formatting options that are wildly inconsistent.
I tried using tab-delimited output, but the "column" command wants to treat all whitespace equal, and putting a "tab" into column as the delimiter requires some shell black magic. I could perhaps just give up and use commas, but Planeswalker cards in MTG have commas in their names which would give me similar issues. Pipe delimited format is almost guaranteed to not collide with anything, but that makes for human unfriendly format if you DON'T use column to output stuff.
And I'd really rather avoid doing some sort of pipe detection to do human or machine friendly output.
Worst case, I figure I can output everything as JSON or some other text-friendly format and just provide a formatter tool that takes the output of my other tools and formats them as you wish, but that just adds complexity.
Perhaps the answer is just "in your tools, be consistent." And I might just have to go that route. But I was hoping there was actually a style guide to "recommended output format" for command line tools. I've tried poking around, and the Cat-v Considered Harmful site has a lot of complaints for what tools SHOULDN'T be doing, but not much for what they should.