
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Simple Typescript CLI options parser.
Parse process arguments into options.
const options = parseArgs(process.argv.slice(2), {
true: { type: true }, // No value
false: { type: false }, // No value
string: { type: String }, // String value
number: { type: Number, alias: 'b' }, // Number value
});
Read the options.
options.get('true'); // true | undefined
options.get('false'); // false | undefined;
options.getAll('string'); // string[]
options.getRequired('number'); // number (or throw)
options.names; // array of all parsed named options
options.positional; // All un-named (positional) options
The get
method returns the last value if the argument is repeated.
const options = parseArgs(['--foo=1', '--foo=2'], {
foo: { type: Number },
});
options.get('foo'); // 2
Errors are thrown...
// Throws because --foo is not an option.
const options = parseArgs(['--foo'], {
bar: { type: String },
baz: { type: true },
});
// Throws because --bar requires a value.
const options = parseArgs(['--bar'], {
bar: { type: String },
baz: { type: true },
});
// Throws because --baz does not accept a value.
const options = parseArgs(['--baz=1'], {
bar: { type: String },
baz: { type: true },
});
All arguments following --
are treated as positional (unnamed) options, even if they start with hyphens.
const options = parseArgs(['--foo', '--', '--bar'], {
foo: { type: true },
bar: { type: true }
});
options.has('bar'); // false
options.names; // ['foo']
options.positional; // ['--bar']
FAQs
Simple Typescript CLI options parser.
We found that cliopts 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.