CLI Argument Parser
github.com
2
Leaving SiteNav
External Link Disclaimer
You are about to visit github.com. This website is not operated by us. We are not responsible for its content or privacy practices.
About this website
The complete solution for Node.js command-line interfaces, providing argument parsing, option handling, subcommand support, and automated help generation with over 28,000 GitHub stars and millions of weekly downloads. The library enables developers to describe their CLI declaratively using a fluent chainable API, defining options with short flags and long names, default values, required flags, negatable booleans, and variadic arguments that capture multiple values. Option types include boolean flags, value options that consume the next argument, optional value options using square bracket syntax, and negatable options using a no- prefix pattern. The parsing engine handles combined short flags, equals-sign value assignment, positional arguments, and double-dash passthrough for raw argument forwarding. Command and subcommand support allows building multi-command programs where each subcommand has its own options, arguments, and action handler, with automatic help generation showing usage syntax, available options, argument descriptions, and command examples. The help system can be customized with usage strings, descriptions, summary text, help groups for organizing options, and display-after-error behavior. Action handlers receive parsed options and command arguments as typed parameters, with async support through parseAsync. TypeScript definitions are included, providing type inference for option names, argument types, and handler signatures. The library supports lifecycle hooks for running setup or teardown code before or after command execution, custom event listeners for intercepting option and command processing, and configurable parsing behavior including positional options and permissive mode for unknown flags. ESM-only since version 15, the library maintains a clean migration path and provides comprehensive examples for every feature.
Statistics
2
Views
0
Clicks
0
Like
0
Dislike