0.2.0 • Published 7 years ago
oh-command v0.2.0
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" }
}