{"id":17046,"library":"parse-help","title":"Parse CLI Help Output","description":"parse-help is a JavaScript utility for programmatically parsing the help output of command-line interfaces, extracting structured information about their flags, options, and aliases. It provides a structured object representation of CLI options, making it easier to analyze or process them within other tools. The current stable version is 2.0.0. The package is maintained by Sindre Sorhus, known for a high volume of small, focused utility packages, typically implying a stable but not necessarily rapid release cadence unless new features or breaking changes warrant it. A key differentiator is its focus specifically on parsing *help output* rather than building a CLI from scratch or parsing `argv` directly, making it useful for introspection or documentation generation from existing CLIs.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/parse-help","tags":["javascript","parse","help","cli","argv","command-line","man","flags","arguments"],"install":[{"cmd":"npm install parse-help","lang":"bash","label":"npm"},{"cmd":"yarn add parse-help","lang":"bash","label":"yarn"},{"cmd":"pnpm add parse-help","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Since v2.0.0, parse-help is a pure ESM module and must be imported using ES modules syntax. CommonJS `require()` is no longer supported.","wrong":"const parseHelp = require('parse-help');","symbol":"parseHelp","correct":"import parseHelp from 'parse-help';"}],"quickstart":{"code":"import parseHelp from 'parse-help';\n\nconst helpOutput = `\n\tUsage\n\t  $ my-cli <command> [options]\n\n\tOptions\n\t  -v, --verbose    Enable verbose logging\n\t  --config <path>  Specify a configuration file (default: config.json)\n\t  -h, --help       Show help information\n\n\tExamples\n\t  $ my-cli start\n\t  $ my-cli build --config custom.json\n`;\n\nconst parsed = parseHelp(helpOutput);\n\nconsole.log('Parsed Flags:', JSON.stringify(parsed.flags, null, 2));\nconsole.log('Parsed Aliases:', JSON.stringify(parsed.aliases, null, 2));\n\n/*\nOutput would be:\nParsed Flags: {\n  \"verbose\": {\n    \"alias\": \"v\",\n    \"description\": \"Enable verbose logging\"\n  },\n  \"config\": {\n    \"description\": \"Specify a configuration file (default: config.json)\"\n  },\n  \"help\": {\n    \"alias\": \"h\",\n    \"description\": \"Show help information\"\n  }\n}\nParsed Aliases: {\n  \"v\": \"verbose\",\n  \"h\": \"help\"\n}\n*/","lang":"javascript","description":"Demonstrates how to import and use `parseHelp` to process a sample CLI help string and output the structured flags and aliases."},"warnings":[{"fix":"Ensure your project is configured for ESM. If using Node.js, add `\"type\": \"module\"` to your `package.json` or use `.mjs` file extensions. Update `require('parse-help')` to `import parseHelp from 'parse-help';`.","message":"parse-help v2.0.0 is a pure ESM module. It no longer supports CommonJS `require()` and must be used with `import` statements in an ESM environment.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade your Node.js environment to version 12 or higher. To maintain compatibility with older Node.js versions, you must stick to parse-help v1.x.","message":"Node.js 12 or newer is now required for parse-help v2.0.0. Older Node.js versions are not supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Provide well-formatted help text that resembles common CLI help output. Test `parseHelp` with various actual outputs from your target CLIs to ensure correct parsing.","message":"The package specifically parses 'help output' as a string. It does not execute a CLI or interact with `process.argv` directly. The quality and format of the output heavily depend on the consistency and standard adherence of the input help string.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Change your import statement from `const parseHelp = require('parse-help');` to `import parseHelp from 'parse-help';` and ensure your project is configured for ESM (e.g., `\"type\": \"module\"` in `package.json`).","cause":"Attempting to `require()` parse-help in a CommonJS context when parse-help is a pure ESM package.","error":"ERR_REQUIRE_ESM"},{"fix":"Ensure the file where you are using the import statement is treated as an ES module. This typically means adding `\"type\": \"module\"` to your `package.json` or changing the file extension to `.mjs`.","cause":"Using `import parseHelp from 'parse-help';` in a file that Node.js is treating as CommonJS.","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null}