houston_console
v0.0.3
Published
Houston allows you to create command-line commands for NodeJS. Your console commands can be used for any recurring task, such as cronjobs, imports, or other batch jobs. Inspired by symfony console component
Downloads
15
Maintainers
Readme
houston
Houston allows you to create command-line commands for NodeJS. Inspired by Symfony console component
Installation
$ npm install --save houston_console
Your first command
./commands/TestCommand.coffee
BaseCommand = require("houston_console").Command
class TestCommand extends BaseCommand
name: 'test:command'
description: 'Test command'
execute: ()->
console.log 'executed!'
module.exports = new TestCommand
Run commands
First, create your console executable file:
$ vim houston
Add your commands to the houston:
#!/usr/bin/env coffee
console = require("houston_console").console
commandList = []
commandList.push( require("./commands/TestCommand.coffee") )
console(commandList)
Make houston executable
$ chmod +x houston
Run:
$ ./houston test:command
Add run options to the command
BaseCommand = require("houston_console").Command
class TestCommand extends BaseCommand
name: 'test:command'
description: 'Test command'
options: [
{
option: "-f, --force"
description: "Force execute flag"
}
]
execute: (options)->
console.log 'force:', options.force
console.log 'executed!'
module.exports = new TestCommand
Run:
$ ./houston test:command -f
Result:
$ ./houston test:command -f
force: true
executed!
Handle command argument:
BaseCommand = require("houston_console").Command
class TestCommand extends BaseCommand
name: 'test:command'
description: 'Test command'
options: [
{
option: "-f, --force"
description: "Force execute flag"
}
]
execute: (param, options)->
console.log 'argument:', param
console.log 'executed!'
module.exports = new TestCommand
$ ./houston test:command passedArgument
Result:
$ ./houston test:command passedArgument
argument: passedArgument
executed!