A complete library to quickly develop CLI programs. Check out the features:
- Process ARGV
- Custom args array
- Shorthand options (Eg.: -f, -g)
- Default values for options
- Flag options (that don't receive any value)
- Grouped flag shorthands (Eg.: -abc)
- Commands
- Help flag and output
- Version flag to execute custom version output
- Callback for commands
- Read modules in a directory as commands
Get Started
const Eclipt = require('../lib/eclipt.js');
let cli = new Eclipt(
'my-cli-tool',
{
'opt-1': [ false, 'A cool options', 'string' ],
'flag-1': [ false, 'A cool flag' ],
'flag-2': [ 'f', 'A flag with a shorthand notation' ],
'opt-2': [ false , 'An option with a default value', 'string', 'my-default' ]
}
);
let input = cli.execute();
console.log(input);
Reporting Bugs
If you have found any problems with this module, please:
- Open an issue.
- Describe what happened and how.
- Also in the issue text, reference the label
~bug
.
We will make sure to take a look when time allows us.
Proposing Features
If you wish to get that awesome feature or have some advice for us, please:
- Open an issue.
- Describe your ideas.
- Also in the issue text, reference the label
~proposal
.
Contributing
If you have spotted any enhancements to be made and is willing to get your hands
dirty about it, fork us and
submit your merge request
so we can collaborate effectively.
Reference
Options Object
An object containing CLI options definition. Each key in the object is the name
of an option and has assigned to it an array with the following data:
string: [
false || character
string
null || string
null || string
]
Constructor
To create a new CLI, use the Eclipt constructor with the following arguments:
let cli = new Eclipt(
'my-tool',
options,
settings
);
These are the settings supported by the constructor:
{
expectedArgs: array,
noArgs: boolean,
requireCommand: boolean,
getVersion: aFunction,
onOutput: aFunction
}
Commands
You can add commands to your tool with cli.setCommand
as follows:
cli.setCommand(name, {
expectedArgs: array,
options: options,
summary: string,
callback: aFunction,
noArgs: boolean
});