argp is a command-line option parser inspired by the GNU argp C library. It focuses on robust parsing of GNU-style options, automatic generation of comprehensive help, usage, and version messages with proper line-wrapping at 80 columns. A key design principle is its 'zero memory footprint' after parsing, achieved by uncaching the module and deleting properties once all input parameters are processed. The package, currently at stable version 1.0.4, offers basic error checking, support for command configuration, and an evented system for customization. It differentiates itself through its strict adherence to GNU-style parsing conventions and its minimal post-execution resource usage, making it suitable for CLI tools prioritizing resource efficiency and standard compliance.
npm install argpVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic parsing of GNU-style options and arguments, automatic help message generation, and version display.
Prefix your parser configuration chain with `.createParser({ once: true })` or `.createParser()` if you need to reuse the parser. For example: `require("argp").createParser({ once: true }).description(...)`.Be aware of its synchronous nature. If performance is extremely critical at startup or in a highly concurrent environment, consider manually providing metadata instead of relying on `readPackage()`.
Use `require()` syntax for importing `argp`. If integrating into an ESM project, you might need to use a CommonJS wrapper or a transpilation step (e.g., Babel, TypeScript) to allow `require()` calls within ESM.
If you need to parse arguments multiple times or manage multiple distinct CLI contexts, omit the `once: true` option when calling `createParser()` or manually re-`require('argp')` for each new parsing cycle.Ensure you call `.createParser()` before chaining configuration methods: `require('argp').createParser().description(...)`.Use the CommonJS `require()` syntax: `const argp = require('argp'); const parser = argp.createParser();`.Define the option using `.option()` in your parser configuration or ensure that arguments are being passed correctly and not interpreted as undefined options.
No dependency data recorded yet.