4 ms·
Coming from other languages it's very confusing what this library does exactly. The screenshots make it look like a full shell, but looking closer it seems to b
by toupeira 11y ago
Coming from other languages it's very confusing what this library does exactly. The screenshots make it look like a full shell, but looking closer it seems to be more of a high-level API that combines readline and optparse functionality. It might be helpful to split up these parts and explain how they improve on using the builtin NodeJS readline module and something like optparse-js.
Also, a question about piping: in your example the "say" command is hard-coded to use the argument called "words", and the "reverse" command is hard-coded to read from standard input. This seems very limited compared to piping in a real shell, shouldn't each command receive a string/array of input and return output so they can be piped to each other without having to know about it?
- dc2 11y agoI get you. Yes, it does combined readline and optparse-type functionality. It's similar to Commander.js, with the exception that you have the option of staying in the "shell" after the first command executes, and then it is its own environment with its own commands. On piping, I hard coded those to keep it short. Every single command can receive "args.stdin", which is a stdin stream from previous commands. To pipe out, the "this.log" command does all of the heavy lifting. So all you would need to do is expect both "args.stdin" and "args.words" - that would cover input both from a directly executed command as well as stdin. This works very well in practice.