@ianwalter/cli
v4.1.0
Published
A utility to help build command-line and package.json driven applications
Downloads
53
Maintainers
Readme
@ianwalter/cli
A utility to help build command-line and package.json driven applications
About
This is basically a marriage between pkg-conf
and
getopts
to allow you to build a Node.js application that can be
configured through both the command-line as well as a package.json property.
Installation
yarn add @ianwalter/cli
Usage
Call cli
with a name
and CLI options as options
and get back a single
config Object containing any command-line and package.json values:
const cli = require('@ianwalter/cli')
const config = cli({
name: 'equip',
options: {
type: {
alias: 't',
description: `
The general class of equipment to use. Possible values include
excavator, dumptruck, and cementmixer.
`
},
color: {
alias: 'c',
default: 'red'
}
}
})
An example of some command-line values might look like:
equip -t excavator --amount 3 --active --engine.horsepower 500
An example of some package.json values might look like:
{
"equip": {
"amount": 1,
"color": "yellow"
}
}
Using the examples above, the resulting config would be:
{
type: 'excavator',
color: 'yellow',
amount: 3,
active: true,
engine: {
horsepower: 500
}
}
License
Hippocratic License - See LICENSE
Created by Ian Walter