
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
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.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.