Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
help-version
Advanced tools
Readme
Anything you wanted to do with --help
and --version
:
process.argv
, so you don't have to;version
from your package.json
file;--help
and --version
, in case you need to handle them differently;--help
and exits with the given code;process.argv
, stdout
and stderr
streams, and even process.exit
function — this means testing won't be a problem.#!/usr/bin/env node
var Cli = require('help-version');
var cli = Cli('Usage: my-cat [file]');
cli.version()
//=> "v0.1.0"
if (process.argv.length != 3) {
// Show help and exit with code 1.
cli.help(1);
}
fs.createReadStream(process.argv[2])
.pipe(process.stdout);
Catches --help
and --version
automatically.
$ ./cat.js --help
Usage: my-cat [file]
$ ./cat.js --version
v0.1.0
$ ./cat.js file.txt
contents of file.txt
cli = Cli(helpText, [opts])
helpText
{String | Function} — help text to print on --help
, or function to produce it.Checks opts.argv
for --help
or --version
.
If --help
is found, prints helpText
to opts.stdout
and calls opts.exit
.
If --version
is found, prints app version (determined from the version
field from your local package.json
) to opts.stdout
and calls opts.exit
.
Returns object with two (bound) methods: cli.help([code], [stream])
and cli.version([code], [stream])
.
Option | Default |
---|---|
argv | process.argv.slice(2) |
exit([code]) | process.exit |
stdout | process.stdout |
stderr | process.stderr |
cli.help([code], [stream])
With no arguments, returns the help string.
With one or two arguments, writes it to stream
instead and exits (via opts.exit
) with code
. stream
defaults to opts.stdout
if code==0
and opts.stderr
otherwise.
cli.version([code], [stream])
With no arguments, returns the version string.
With one or two arguments, writes it to the stream
instead and exits (via opts.exit
) with code
. stream
defaults to opts.stdout
if code==0
and opts.stderr
otherwise.
npm install help-version
MIT
FAQs
Handle --help and --version arguments in your CLI application
The npm package help-version receives a total of 49 weekly downloads. As such, help-version popularity was classified as not popular.
We found that help-version demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.