Registry / devops / dreamopt

dreamopt

JSON →
library0.8.0jsnpmunverified

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.

npm install dreamopt
INSTALL
IMPORT
SIG · DREAMOPT
D
dreamopt
devopsjavascriptv0.8.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dreamopt
const dreamopt = require('dreamopt');
import dreamopt from 'dreamopt';
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.

This quickstart demonstrates basic command and option parsing with dreamopt, including argument access, version/help flags, and conditional command execution based on user input.

const dreamopt = require('dreamopt'); const options = dreamopt( [ 'Usage: myapp [options] <command>', '', 'Commands:', ' init <project_name> Initialize a new project', ['Creates a new folder and basic structure.'], ' run <script_path> Execute a script file', ['Requires a path to the script.'], '', 'Options:', ' -v, --version Show version number', ' -h, --help Show help message', ' --verbose Enable verbose logging #boolean' ], process.argv.slice(2) ); if (options.help) { console.log(dreamopt.usage()); process.exit(0); } if (options.version) { console.log('myapp version 1.0.0'); process.exit(0); } switch (options.command) { case 'init': if (options.args.length < 1) { console.error('Error: init command requires a project name.'); process.exit(1); } console.log(`Initializing project: ${options.args[0]} with verbose=${options.verbose || false}`); // Logic to create project break; case 'run': if (options.args.length < 1) { console.error('Error: run command requires a script path.'); process.exit(1); } console.log(`Running script: ${options.args[0]} with verbose=${options.verbose || false}`); // Logic to execute script break; default: console.error('Error: Invalid command. Use --help for usage.'); process.exit(1); }
Debug
Known issues
breakingThe `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.
fix
Migrate to a currently maintained command-line parser like `commander`, `yargs`, or `minimist`.
affects: >=0.8.0
gotchaThis 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.
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.
affects: >=0.8.0
gotchadreamopt 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.
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.
affects: >=0.8.0
gotchaThe 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`.
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.
affects: >=0.8.0
gotchaDespite 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.
fix
Always verify the last publish date and GitHub activity for a package's true maintenance status, regardless of download counts.
affects: >=0.8.0
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use `require('dreamopt')` in a Node.js environment configured for ES Modules.
fix
Convert your project or file to CommonJS, or rewrite the CLI parsing using an ESM-compatible library like `commander` or `yargs`.
Error: Cannot find module 'wordwrap'
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.
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.
SyntaxError: 'with' statement not allowed in strict mode
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.
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.
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies
wordwraprequiredUsed for formatting help output and descriptions in the command-line interface.
Agent activity
4 hits · last 30 days
node
4
Resources