{"id":13088,"library":"dreamopt","title":"dreamopt Command-Line Parser","description":"dreamopt is a JavaScript library designed for parsing command-line arguments, offering a syntax aimed at readability and ease of use. It supports a comprehensive range of features including mandatory and optional arguments, options with values, default values, automatic help generation, and the ability to define commands, subcommands, and nested subcommands. It also includes automatic type coercion for arguments (e.g., to numbers) and allows for custom tags and coercion rules. The library's core differentiator was its declarative, array-based specification format for defining CLI structures. The current stable version, `0.8.0`, was published in July 2012. The package is effectively abandoned, with its last commit over a decade ago. Despite its abandonment, npm download statistics show surprisingly high usage, which may be attributed to it being a transitive dependency in other legacy projects or due to automated processes, rather than active new development.","status":"abandoned","version":"0.8.0","language":"javascript","source_language":"en","source_url":"git://github.com/andreyvit/dreamopt.js","tags":["javascript"],"install":[{"cmd":"npm install dreamopt","lang":"bash","label":"npm"},{"cmd":"yarn add dreamopt","lang":"bash","label":"yarn"},{"cmd":"pnpm add dreamopt","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for formatting help output and descriptions in the command-line interface.","package":"wordwrap","optional":false}],"imports":[{"note":"This package is CommonJS-only and does not support ES Modules. Attempting to use `import` syntax will result in a runtime error in an ESM context.","wrong":"import dreamopt from 'dreamopt';","symbol":"dreamopt","correct":"const dreamopt = require('dreamopt');"}],"quickstart":{"code":"const dreamopt = require('dreamopt');\n\nconst options = dreamopt(\n  [\n    'Usage: myapp [options] <command>',\n    '',\n    'Commands:',\n    '  init <project_name>    Initialize a new project', ['Creates a new folder and basic structure.'],\n    '  run <script_path>      Execute a script file', ['Requires a path to the script.'],\n    '',\n    'Options:',\n    '  -v, --version          Show version number',\n    '  -h, --help             Show help message',\n    '  --verbose              Enable verbose logging #boolean'\n  ],\n  process.argv.slice(2)\n);\n\nif (options.help) {\n  console.log(dreamopt.usage());\n  process.exit(0);\n}\n\nif (options.version) {\n  console.log('myapp version 1.0.0');\n  process.exit(0);\n}\n\nswitch (options.command) {\n  case 'init':\n    if (options.args.length < 1) {\n      console.error('Error: init command requires a project name.');\n      process.exit(1);\n    }\n    console.log(`Initializing project: ${options.args[0]} with verbose=${options.verbose || false}`);\n    // Logic to create project\n    break;\n  case 'run':\n    if (options.args.length < 1) {\n      console.error('Error: run command requires a script path.');\n      process.exit(1);\n    }\n    console.log(`Running script: ${options.args[0]} with verbose=${options.verbose || false}`);\n    // Logic to execute script\n    break;\n  default:\n    console.error('Error: Invalid command. Use --help for usage.');\n    process.exit(1);\n}\n","lang":"javascript","description":"This quickstart demonstrates basic command and option parsing with dreamopt, including argument access, version/help flags, and conditional command execution based on user input."},"warnings":[{"fix":"Migrate to a currently maintained command-line parser like `commander`, `yargs`, or `minimist`.","message":"The `dreamopt` package is abandoned and has not received updates since 2012. It is highly unlikely to be compatible with modern Node.js versions or maintain security patches, making it unsuitable for new projects.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Ensure your project is configured for CommonJS, or use `require()` within an ESM wrapper (if necessary) at your own risk. The recommended fix is to migrate to a modern CLI parser that supports ESM.","message":"This package is CommonJS-only and does not support ES Modules. Using `import` syntax will lead to runtime errors in modern Node.js environments configured for ESM.","severity":"gotcha","affected_versions":">=0.8.0"},{"fix":"There is no direct fix to make `dreamopt` fully compatible with modern Node.js. Consider rewriting the CLI parsing logic using an up-to-date library.","message":"dreamopt requires Node.js version `>=0.4.0`, which is extremely old and unsupported. Running it on modern Node.js environments (e.g., Node.js 16+) may result in unexpected behavior, deprecation warnings, or crashes due to incompatible APIs and language features.","severity":"gotcha","affected_versions":">=0.8.0"},{"fix":"If using TypeScript, you would need to write your own declaration file (`.d.ts`) for `dreamopt` or, preferably, migrate to a CLI parsing library that includes or has community-supported types.","message":"The package does not ship with TypeScript type definitions, nor are community-contributed types available on DefinitelyTyped. This means developers using TypeScript will lose type safety and autocompletion when interacting with `dreamopt`.","severity":"gotcha","affected_versions":">=0.8.0"},{"fix":"Always verify the last publish date and GitHub activity for a package's true maintenance status, regardless of download counts.","message":"Despite being abandoned, `dreamopt` shows a high volume of downloads on npm. This should not be interpreted as a sign of active maintenance or current relevance. It likely indicates its presence as a legacy dependency in older projects or potential bot activity, not current community adoption.","severity":"gotcha","affected_versions":">=0.8.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Convert your project or file to CommonJS, or rewrite the CLI parsing using an ESM-compatible library like `commander` or `yargs`.","cause":"Attempting to use `require('dreamopt')` in a Node.js environment configured for ES Modules.","error":"TypeError: require is not a function"},{"fix":"Ensure `wordwrap` is explicitly listed in your `package.json` dependencies and try `npm install`. If the issue persists, it's a strong indicator of deeper compatibility problems, and migration to a modern CLI parser is recommended.","cause":"The `wordwrap` dependency (a transitive dependency of `dreamopt`) is not correctly installed or resolved, possibly due to issues with very old versions or `npm`'s dependency resolution heuristics in a modern environment.","error":"Error: Cannot find module 'wordwrap'"},{"fix":"This error points to fundamental incompatibility with modern JavaScript engines or strict mode environments. There is no practical fix other than replacing `dreamopt` with a modern, actively maintained alternative.","cause":"Older JavaScript code in `dreamopt` might use features like the `with` statement, which are disallowed in strict mode or by modern JavaScript engines, leading to parsing errors.","error":"SyntaxError: 'with' statement not allowed in strict mode"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}