headquarters
v0.2.4
Published
Issue commands to your program while it is running.
Downloads
4
Readme
Headquarters
Issue commands to your program while it is running.
Installation
$ npm install --save headquarters
var hq = require('headquarters');
Methods
command
hq.command(name, action);
Sets a command.
Parameters
- name the name of the command (string)
- action called whe the command is issued (function)
Type your command name in the console as your program is running followed by any additional parameters. The action function for that command will then be executed, with the additional parameters passed into the first argument of the function as an array.
raw
hq.raw(action);
Specify what to do with raw input (i.e. issue a command with no command name).
Parameters
- action called when raw input (input with no established command) is entered (function)
The input is broken up by spaces, put into an array, and then passed into the action callback as a single parameter. Named commands can still be set and executed normally.
Example
var hq = require('headquarters');
hq.command('say', function (params) {
console.log(params.join(' '));
});
In the command line, start your program:
$ node my_program.js
Then use your custom command:
say hello world!
Profit:
hello world!
Pre-existing Commands
Commands that are already built into headquarters:
- 'quit' stops your process from running
- 'curl' retrieves a response from a url argument