Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
maddenpj committed Nov 30, 2011
1 parent 2615a1b commit a67a353
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions README.md
Expand Up @@ -7,41 +7,46 @@

Code:

var control = new ControlPort();
control.start(6000);
var control = new ControlPort();
control.start(6000);

control.register('add', function (a,b) {
return (a+b);
});

control.register('shutdown', function () {
process.exit(0);
});
control.register('menu') function () {
var out = '--- Menu ---\n\tshutdown - Kills the process\n';
out+= '\tadd <A> <B> - Adds the arguments\n';
});
control.register('add', function (a,b) {
return (a+b);
},'Adds two numbers');
control.register('shutdown', function () {
process.exit(0);
}'Shuts down process');


In action:

$ nc localhost 6000
Node> menu
--- Menu ---
shutdown - Kills the process
add <A> <B> - Adds the arguments
Node> add 2 3
5
Node> shutdown
$
$ nc localhost 6000
Node> menu
--- Menu ---

add <a> <b> - Adds two numbers

shutdown - Shuts down process

Node> add 2 3
5
Node> shutdown
$


## Features
Set your own Prompt
* Set your own Prompt!

var control = new ControlPort('Server4');

Auto argument parsing:
arg1, arg2, and arg3 will be passed to command callback

* Unlimited Commands!

control.register(name, callback, menuDescription);

* Auto Menu Generation!

* Auto argument parsing:

arg1, arg2, and arg3 will be passed to command callback

Node> command arg1 arg2 arg3
Node> command arg1 arg2 arg3

0 comments on commit a67a353

Please sign in to comment.