cli-nano is a lightweight library for building command-line interfaces (CLIs) in Node.js, offering functionality similar to `yargs` or Node.js's built-in `parseArgs()`. It supports parsing positional arguments, flags, and options with robust configuration capabilities. The current stable version is 1.2.2, with releases occurring fairly frequently, often including minor bug fixes and features, sometimes with breaking changes within minor versions as seen with v1.2.0 and v1.0.0. Its key differentiators include a minimal footprint, zero external dependencies, and extensive configurability for defining argument types, aliases, defaults, and generating help output, making it a powerful alternative to heavier CLI libraries while providing more features than the native `parseArgs()` method. It is designed for Node.js environments and ships with TypeScript types for enhanced developer experience.
npm install cli-nanoVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a CLI command with positional arguments, various options (booleans, numbers, strings, arrays), aliases, default values, and a version/help display. It then parses `process.argv` and logs the results, showcasing basic argument access and conditional logic based on flags.
Update `command.positionals` from `[{ name: 'arg', ... }]` to `{ arg: { ... } }`.Change `command.description` to `command.describe` in your CLI configuration.
Rename the `positional` property in your command configuration to `positionals`.
Always access parsed options using their camelCase equivalent (e.g., `args.myFlag`). If you need kebab-case for help display, set `helpFlagCasing: 'kebab'` in your config, but this does not change the parsed argument key.
Ensure all `required: true` arguments and options are supplied when running the CLI. For example, if 'input' is required, run `your-cli-command 'some-value'`.
Provide values that match the expected type for each option. For a number type, ensure a valid numeric string is passed (e.g., `--port 8080`, not `--port abc`).
Check for typos in the flag name or define the option in your `parseArgs` configuration. If it's an intended flag, add it to `config.options` with its type and description.
No dependency data recorded yet.