getarg is a lightweight and fast command-line argument parser designed for Node.js applications, currently at version 0.0.5. It focuses on providing a simple API for defining, parsing, and validating CLI arguments, including support for required parameters, basic type enforcement (string, number, json, any), aliases, custom help messages, and inter-argument dependencies. Unlike more comprehensive CLI frameworks such as Yargs or Commander, `getarg` prioritizes minimalism and directness, making it suitable for smaller scripts or cases where extensive feature sets are not required. As a pre-1.0 release, its API might still evolve, though the core functionality is designed for quick integration into Node.js projects requiring basic argument handling.
npm install getargVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define required string arguments with aliases and inter-dependencies, add a boolean flag, and how the parser processes valid inputs, showing the structured output. It also implicitly highlights the built-in help display and validation behavior.
Always pin to exact versions (e.g., `"getarg": "0.0.5"`) and review release notes for updates.
Be aware that invalid input will terminate your script. Consider wrapper functions or alternative parsers if programmatic error handling is critical.
Evaluate if `getarg`'s capabilities meet your project's specific CLI requirements. For complex CLI structures, consider libraries like `commander` or `yargs`.
Implement additional post-parsing logic to validate complex inter-argument dependencies or value-based conditions.
Perform manual type conversion and validation after `getArgs` has processed the input, especially for array inputs or custom data types.
Ensure that parameters expecting a string value are provided with one. For instance, `node cli.js --file "./input.txt"` or `-f value`.
Provide a valid integer or floating-point number for parameters expecting a numeric type, e.g., `node cli.js --count 123`.
No dependency data recorded yet.