simple-bin-help is a utility library for Node.js CLI (Command Line Interface) scripts, providing essential features like automatic help message display, argument validation, and update notifications. Currently stable at version 1.8.0, its release cadence is moderate, with updates typically focusing on dependency bumps and minor improvements rather than rapid feature additions. Key differentiators include its consolidated approach to common CLI boilerplate, offering a single function call to handle `--help` / `--version` flags, enforce minimum argument counts (`minArguments`), and integrate `update-notifier` for prompting users about new versions. It allows for customizable help strings, an `onFail` callback for custom error handling, and a `noExit` option to control the default `process.exit()` behavior, providing flexibility for different CLI design patterns.
npm install simple-bin-helpVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic argument validation and automatic help/version display for a Node.js CLI script, using `minArguments` and a `package.json` path. It also highlights the default `process.exit()` behavior.
To prevent automatic exiting, set the `noExit: true` option in the configuration object. When `noExit` is true, the function returns a boolean indicating success/failure, allowing you to manage exit logic yourself.
Adjust `minArguments` by adding 2 to the number of *actual* required user arguments (e.g., for 1 user arg, set `minArguments: 1 + 2 = 3`).
Ensure `packagePath` is an absolute path or a correct relative path using `path.join(__dirname, '..', 'package.json')` for a typical bin script setup where the script is in `bin/` and `package.json` is in the project root.
Run `npm install simple-bin-help` in your project directory. Ensure the package is listed in your `dependencies` in `package.json` and that `npm install` has been executed.
First, check if your CLI was invoked with `-h`, `--help`, `-v`, or `--version`. If not, verify your `minArguments` setting and the number of arguments provided to the CLI. If you want to prevent automatic exiting by `simple-bin-help`, set the `noExit: true` option in its configuration object.