ARGV
A very simple module called argv
that allows you to:
- Check whether certain flags exist in
process.argv
- Get the value of a flag in
process.argv
Installation
npm install @lando/argv
yarn add @lando/argv
Usage
This module has two functions hasOption
and getOption
.
hasOption
Checks to see if a flag exists in process.argv
.
const argv = require('argv');
const hasDebug = argv.hasOption('--debug'));
getOption
Returns the value of the flag. If the flag is a switch then it will return true|false
by default. If the flag has a string
value it will return that string value.
const argv = require('argv');
console.log(argv.getOption('--debug'));
The above code will produce the following:
node myscript.js --debug
> true
node myscript.js --debug "trill"
> trill
hyperdrive list --debug=trill
> trill
You also can replace the default Boolean value with the defaultValue
option.
const argv = require('argv');
console.log(argv.getOption('--debug', {defaultValue: 'the-truth-is-out-there'}));
node myscript.js --debug
> the-truth-is-out-there
Issues, Questions and Support
If you have a question or would like some community support we recommend you join us on Slack. Note that this is the Slack community for Lando but we are more than happy to help with this module as well!
If you'd like to report a bug or submit a feature request then please use the issue queue in this repo.
Changelog
We try to log all changes big and small in both THE CHANGELOG and the release notes.
Development
git clone https://github.com/lando/argv.git && cd argv
yarn install
If you dont' want to install Node 14 or Yarn for whatever reason you can install Lando and use that:
git clone https://github.com/lando/argv.git && cd argv
lando start
lando node
lando yarn
Testing
yarn lint
yarn test
Releasing
To deploy and publish a new version of the package to the npm
registry you need only create a release on GitHub. That said, in order to create a release and succesfully publish it to npm
you will want to make sure:
- You have tagged the commit you want to deploy in
git
and pushed it up to GitHub
- You have bumped the version in your
package.json
so that it doesn't collide with a version already published to npm
In order to help with the above we recommend you run the convience command yarn release
which will take care of both.
Also note that if you create a "pre-release" it will tag the npm
package with edge
instead of the default latest
tag. Also note that while you can toggle the pre-release checkbox after the initial release creation this will not trigger a new release and/or promote the release from edge
to latest
. If you want to deploy to latest
then create a new release without pre-released checked.
yarn add @lando/argv
yarn add @lando/argv@edge
Contributors
Made with contributors-img.
Other Resources
v1.1.0-beta.1 March 31, 2022