{"library":"process.argv","title":"Process.argv CLI Argument Parser","description":"process.argv is a lightweight and minimal CLI argument parser for Node.js. The current stable version is 1.0.0. While the package does not have a rapid release cadence, its GitHub repository shows copyright updates extending to 2024 and active CI workflows, indicating ongoing maintenance rather than abandonment. It differentiates itself from more feature-rich alternatives like `yargs` or `commander` by intentionally omitting common conveniences such as shortcut flags (e.g., `-f`), built-in help message generation, and space-separated argument values (e.g., `--foo bar`). Instead, it processes arguments strictly in the `--key=value` format, automatically handling nested object structures from hyphenated keys (e.g., `--bar-buz` maps to `config.bar.buz`). This design philosophy prioritizes a small footprint and explicit parsing logic, requiring developers to implement higher-level CLI features themselves.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install process.argv"],"cli":null},"imports":["import argv from 'process.argv'","const argv = require('process.argv')","const processArgv = argv(process.argv.slice(2));"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import argv from 'process.argv';\n\ninterface Config {\n    foo: string;\n    bar: {\n        buz: string;\n    };\n    qux?: boolean;\n    '--'?: string[]; // To capture positional arguments\n}\n\n// Simulate process.argv for demonstration\nconst mockArgs = ['node', 'cli.js', '--foo=hello', '--bar-buz=world', 'file1.txt', 'file2.txt'];\n// In a real CLI, use: argv(process.argv.slice(2))\nconst processArgv = argv(mockArgs.slice(2));\n\nconst config = processArgv<Config>({\n    foo: 'defaultFoo',\n    bar: {\n        buz: 'defaultBuz'\n    },\n    qux: false\n});\n\nconsole.log('Parsed Configuration:', config);\nconsole.log('Foo:', config.foo); // Should be 'hello'\nconsole.log('Bar Buz:', config.bar.buz); // Should be 'world'\nconsole.log('Qux (default):', config.qux); // Should be false\n\n// Access positional arguments (e.g., file1.txt, file2.txt)\nconst positionalArgs = config['--'] || [];\nconsole.log('Positional Arguments:', positionalArgs);","lang":"typescript","description":"Demonstrates parsing CLI arguments into a typed configuration object, applying defaults, and accessing positional arguments. The example includes a `mockArgs` array for easy testing without actual CLI execution.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}