houston_console
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
Last updated 5 years ago by apetrovskyi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install houston_console 
SYNC missed versions from official npm registry.

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!

Current Tags

  • 0.0.3                                ...           latest (5 years ago)

3 Versions

  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |