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
Maintainers
Readme
houston
Houston allows you to create command-line commands for NodeJS. Inspired by Symfony console component
Installation
$ npm install --save houston_consoleYour 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 TestCommandRun commands
First, create your console executable file:
$ vim houstonAdd 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 houstonRun:
$ ./houston test:commandAdd 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 TestCommandRun:
$ ./houston test:command -fResult:
$ ./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 passedArgumentResult:
$ ./houston test:command passedArgument
argument: passedArgument
executed!