Oppa is a typesafe options and arguments parser for Node.js, designed for command-line interfaces. It provides a fluent API for defining command-line arguments, including support for long/short names, aliases, boolean flags (with `--no-` prefix auto-handling), multi-value arguments, and custom validators. A key differentiator is its strong TypeScript integration, which ensures the parsed result is fully type-checked at compile-time, eliminating common runtime errors associated with parsing untyped arguments. It also automatically generates comprehensive `--help` and `--version` output. The current stable version is 0.4.0, released in June 2021, indicating a slower release cadence. It requires Node.js >=10, with specific build fixes for Node.js 10 in versions 0.3.3 and later.
npm install oppaVerified import paths — ran on the pinned version, not inferred.
Demonstrates defining various argument types (string, number, boolean), setting defaults, applying validators, and handling parsed results with TypeScript safety. It also shows how to configure `noExit` and `throwOnError` for programmatic control.
Evaluate if the current feature set meets your application's needs. If active development, latest Node.js compatibility, or rapid bug fixes are critical, consider alternative argument parsers.
Initialize `oppa` with `{ noExit: true }` to prevent automatic process termination. You will then need to handle program termination or continuation explicitly in your application logic.Ensure your Node.js environment is version 10 or greater. Version 0.3.3 specifically addressed a build issue for Node.js 10, making it the minimum recommended version for stable Node.js 10 support.
Initialize `oppa` with `{ allowUnknown: true }` to collect unknown arguments in the `result.unknown` array instead of throwing an error. This allows your application to gracefully handle or ignore unrecognized input.Initialize `oppa` with `{ noHelpAlias: true }` and/or `{ noVersionAlias: true }` to prevent the automatic creation of `-h` and `-v` aliases, freeing them up for your custom argument definitions.Ensure that optional arguments are checked for `undefined` before use, or provide `defaultValue` in your `.add()` definition. If it's a type mismatch, explicitly set the `type` property (e.g., `type: 'string'`) in your argument definition, and TypeScript will catch such errors at compile-time.
Either define the argument using `.add()` in your parser configuration, or initialize `oppa` with `{ allowUnknown: true }` to collect unknown arguments in the `result.unknown` array instead of throwing an error.Initialize `oppa` with `{ noExit: true }` to prevent automatic process termination. This allows test runners to complete without interruption and gives your application explicit control over exiting.Review the `validator` function for the specific argument and ensure it correctly handles expected input ranges or formats. Inform the user about the valid input for that argument in the help text.
No dependency data recorded yet.