Hacker News new | ask | show | jobs
by chrissoundz 2495 days ago
I really enjoy seeing new ideas around interfaces. But I do wonder, rather than creating a new shell, couldn't we have a 'json/structured' mode for cli programs - and maintain compatibility with existing shells? For example if it was toggled with a SHELL_FORMAT environment variable?

What issues could be faced with this approach?

4 comments

PowerShell has an IMO good answer to this: if you run a classic CLI program, its output is interpreted as an array of strings (lines), so if you pipe the output, you have a way to process it into something object-like.

Having a toggle creates the problem that you have to write two implementations for your tools, or you end up having to memorize which commands can run in which modes. It's easier to have a consistent pattern and a way to up-convert existing CLI programs.

Mario uses Python objects in pipelines instead of plain text.

https://github.com/python-mario/mario

Oh lordy where to begin.
Ahh yes. Here’s where to begin: https://xkcd.com/927/