minish
Minish makes it easy to write applications that interact with a user using a simple shell-like command-line interface.
Installing
$ npm install --save minish
Usage
Starting an interactive command-line session is very simple. Just require minish, declare some commands and start a command prompt:
var shell = ; // 'hello' commandshell; shell; // start prompting for commandsshellprompt;
Commands accept arguments and options. Both of these get parsed with minimist and are passed to the callback with command context object:
shell;
Minish makes it simple to ask for input. It can also ask for passwords discretely:
// ask for a password without revealing its characters:shell;
Let's try something more complicated:
var shell = ; // 'hello' commandshell; // 'echo' commandshell; // 'ask' commandshell; // 'passwd' commandshell; // 'quit' and 'exit' commandsshell; // override default 'command not supported' handlershell; // display a welcome messageshell;shell; // start prompting for commandsshellprompt"> ";
Check out minish TypeScript typings for a quick overview of the rest of available API.