{"library":"simple-bin-help","title":"Simple CLI Help and Sanity Checks","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install simple-bin-help"],"cli":null},"imports":["require('simple-bin-help')({ minArguments: 3, help: '...' });","const simpleBinHelp = require('simple-bin-help'); simpleBinHelp({ minArguments: 3, help: '...' });","const { default: simpleBinHelp } = await import('simple-bin-help'); simpleBinHelp({ minArguments: 3, help: '...' });"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"#!/usr/bin/env node\n// filename: my-cli-tool.js\n\nconst path = require('path');\nconst simpleBinHelp = require('simple-bin-help');\n\n// Configure help and argument validation\nsimpleBinHelp({\n  minArguments: 3, // Requires 'node', 'my-cli-tool.js', and one more argument\n  packagePath: path.join(__dirname, '..', 'package.json'), // Path to your project's package.json\n  help: 'Usage: my-cli-tool <required-argument>\\n\\nThis tool processes a single string argument.',\n  // By default, simple-bin-help calls process.exit() if validation fails or help/version is shown.\n  // Set noExit: true if you want to handle the exit logic yourself.\n  noExit: false\n});\n\n// If the script reaches this point, arguments were valid and help/version was not displayed.\nconsole.log(`Hello from my-cli-tool!`);\nconsole.log(`Received argument: ${process.argv[2]}`);\nconsole.log('Continuing with main CLI logic...');\n\n// Example usage:\n// 1. Create a dummy ../package.json: {\"name\": \"my-cli-tool\", \"version\": \"1.0.0\"}\n// 2. Run: `node my-cli-tool.js \"some value\"` (Valid)\n// 3. Run: `node my-cli-tool.js` (Shows help and exits)\n// 4. Run: `node my-cli-tool.js -h` (Shows help and exits)\n// 5. Run: `node my-cli-tool.js -v` (Shows version and exits)","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}