oh-command

0.2.0 • Public • Published

oh-command

A nodejs commands wrapper for convenience.

Why

If you are using nodejs commands as below,

node ./index.js --command=build --module=myapp

# or via npm scripts
npm run build -- --module=myapp

consider making it more elegant.

Usage

install

npm i oh-command -g

adding .oh-command.json config file

{
  "root": "",
  "commands": [
    {
      "name": "build",
      "aliases": [ "b" ],
      "options": [
        { "name": "module", "type": "String", "description": "Specifies module to build." },
        { "name": "all", "type": "Boolean", "description": "Build all modules." }
      ],
      "description": "Builds source code and places it into the output path."
    },
    {
      "name": "serve",
      "aliases": [ "s" ],
      "options": [
        { "name": "module", "type": "String" }
      ]
    }
  ],
  "entry": "index.js"
}

Now you can use command as follows.

oc build --module=myapp
oc serve --module=myapp

The entry must be a function and the command and arguments will be passed in, for example.

# command
oc build --module=myapp
// entry
module.exports = function(command, commandArgs) {
  console.log(command); // build
  console.log(commandArgs); // { module: "myapp" }
}

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i oh-command

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

9.15 kB

Total Files

8

Last publish

Collaborators

  • ikeq