Super-duper lightweight no-dependency alternative to clap
clap. It wasn't quite what I wanted, so I wrote my own :P
This is refactored out of my main PhDcodebase, so if you're wondering why there aren't very many commits, that's why.
- Current version:
- API Docs: https://starbeamrainbowlabs.com/code/applause-cli/
- Changelog: https://github.com/sbrl/applause-cli/blob/master/Changelog.md
npm install applause-cli --save
"use strict";;// HACK: Make sure __dirname is defined when using es6 modules. I forget where I found this - a PR with a source URL would be great :Dconst __dirname = ;// Locate your package.json - this assumes it's sitting in the same directory as this fileconst package_json_filepath = path;// Create a new CLI parser// The name description, version number, etc are all populated from thereconst cli = package_json_filepath;clicli// An argument just for this subcommand;console;
The full API documentation can be found here: (TODO: Insert a link here)
Several argument types are currently supported. They are specified as the 4th argument to the
.argument() command (either globally or on a specific subcommand):
||Just a string.|
||An integer (
||A floating-point number (
In addition, a function can be passed instead of a string defining the type of an argument, and that function will be called with a single argument to parse values instead:
- I'm using it for the main Node.js application for my PhD in Computer Science!
- (Are you using this project? Get in touch by opening an issue)
Contributions are welcome as PRs! Don't forget to say that you donate your contribution under the Mozilla Public License 2.0 in your PR comment.
This project is licensed under the Mozilla Public License 2.0. See the
LICENSE file in this repository for the full text.