cmd-console
v0.2.3
Published
cmdlet-based console
Downloads
16
Readme
cmd-console
cmdlet based console.
WHY
The npm package "cmdlet" is a simple framework to develop micro-command (aka: cmdlet) based system, however, in order to execute the cmdlets the end user has to input the "node index" repeatly as following:
$ node index hello[world]
$ node index foo*bar
$ node index add[1,2]
$ node index sub[a:1, b:2]
This package provides a console so that the end user can execute cmdlet just like in a shell (note: '? >' is the built-in prompt, not a part of user input) :
$ node myapp
? > hello(world)
? > foo*bar
? > add[1,2]
? > sub[a:1, b:2]
? >
? > .exit
--- bye ---
$
uses ".exit" or CTRL+C to exit the console.
One good thing is that because the user input is now parsed in our own shell, the cmdlet parameters can be enclosed in either fn(a, b) or fn[a, b] format, otherwise in bash shell you have to run a cmdlet as "fn(a, b)".
API
run(): starts console
/**
* Example how to combine both packages to run a console.
*/
const cmdlet = require('cmdlets');
//load supported cmdlets
cmdlets.addModule( __dirname + '/sys', 'cmd-system');
cmdlets.addModule(__dirname + '/util', 'cmd-util');
...
//now starts our command console
require('cmd-console').run();