cli-vir is a command-line interface (CLI) argument parser for Node.js, built with a strong emphasis on type safety for parsed arguments. The current stable version is 1.0.3, indicating active development with frequent patch releases addressing minor issues and dependency updates. Key differentiators include its flexible handling of flag formats (single/double dashes, short/long forms), support for case-insensitive flag names across camelCase, kebab-case, and snake_case variants, and robust options to restrict argument values to specific sets or convert truthy/falsy strings to booleans. It provides comprehensive type inference for parsed values and automatically generates man-page-style documentation for parsing failures. This library streamlines CLI development by abstracting away common parsing complexities and enhancing developer experience with strong type guarantees. It requires Node.js version 22 or higher.
npm install cli-virVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to parse command-line arguments with type safety, defining flags and positional arguments, and handling multiple values for a flag. It shows the basic setup with `parseArgs` and how to access the typed results.
Update `ParsedArg` to `ParsedArgs` in your type annotations: `import type { ParsedArgs } from 'cli-vir';`Consult the commit history (v0.2.0...v1.0.0) for detailed changes and adjust your code accordingly. Pay attention to how `binName` is configured if you use multiple entry points.
Ensure your project's Node.js environment is updated to version 22 or later. You can use a tool like `nvm` to manage Node.js versions.
Always provide `{ importMeta: import.meta }` in the options object when calling `parseArgs` from your main CLI entry point.Change your import statement to use ESM syntax: `import { parseArgs } from 'cli-vir';` and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).Adjust your `FlagRequirement` in the argument definition (e.g., `FlagRequirement.Required` for a string value) or ensure the CLI input matches the expected type (e.g., pass the flag without a value for a boolean flag).
Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`) and you are running Node.js version 12.0.0 or higher, where `import.meta` was introduced for ESM modules.
No dependency data recorded yet.