What's the âUnix Wayâ to propery format tabular output?

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
3
down vote
favorite
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?
Some background:
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.
command-line text-formatting
add a comment |Â
up vote
3
down vote
favorite
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?
Some background:
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.
command-line text-formatting
1
Useful - 12factor.net & catb.org/esr/writings/taoup/html
â slmâ¦
Jul 30 at 3:12
1
I think this is the part you're looking for - catb.org/esr/writings/taoup/html/ch05s01.html.
â slmâ¦
Jul 30 at 3:18
your data above seems to be in CSV format, most tools that process tabular data can handle CSV.
â Jasen
Jul 30 at 8:33
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
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?
Some background:
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.
command-line text-formatting
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?
Some background:
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.
command-line text-formatting
asked Jul 30 at 2:55
Zoey Boles
1162
1162
1
Useful - 12factor.net & catb.org/esr/writings/taoup/html
â slmâ¦
Jul 30 at 3:12
1
I think this is the part you're looking for - catb.org/esr/writings/taoup/html/ch05s01.html.
â slmâ¦
Jul 30 at 3:18
your data above seems to be in CSV format, most tools that process tabular data can handle CSV.
â Jasen
Jul 30 at 8:33
add a comment |Â
1
Useful - 12factor.net & catb.org/esr/writings/taoup/html
â slmâ¦
Jul 30 at 3:12
1
I think this is the part you're looking for - catb.org/esr/writings/taoup/html/ch05s01.html.
â slmâ¦
Jul 30 at 3:18
your data above seems to be in CSV format, most tools that process tabular data can handle CSV.
â Jasen
Jul 30 at 8:33
1
1
Useful - 12factor.net & catb.org/esr/writings/taoup/html
â slmâ¦
Jul 30 at 3:12
Useful - 12factor.net & catb.org/esr/writings/taoup/html
â slmâ¦
Jul 30 at 3:12
1
1
I think this is the part you're looking for - catb.org/esr/writings/taoup/html/ch05s01.html.
â slmâ¦
Jul 30 at 3:18
I think this is the part you're looking for - catb.org/esr/writings/taoup/html/ch05s01.html.
â slmâ¦
Jul 30 at 3:18
your data above seems to be in CSV format, most tools that process tabular data can handle CSV.
â Jasen
Jul 30 at 8:33
your data above seems to be in CSV format, most tools that process tabular data can handle CSV.
â Jasen
Jul 30 at 8:33
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459250%2fwhats-the-unix-way-to-propery-format-tabular-output%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Useful - 12factor.net & catb.org/esr/writings/taoup/html
â slmâ¦
Jul 30 at 3:12
1
I think this is the part you're looking for - catb.org/esr/writings/taoup/html/ch05s01.html.
â slmâ¦
Jul 30 at 3:18
your data above seems to be in CSV format, most tools that process tabular data can handle CSV.
â Jasen
Jul 30 at 8:33