{"id":16787,"library":"cli-list","title":"CLI List Parser","description":"cli-list is a utility package designed to parse command-line argument lists, typically sourced from `process.argv`, into a structured array of arrays. It specializes in breaking down a single array of arguments, where items might be comma-separated, into sub-arrays at each comma delimiter. This maintains the \"argv style\" of the sub-arrays, making them suitable for direct consumption by other command-line argument parsers like `minimist`. The current stable version is 1.0.0, which was released recently and updated the codebase to modern JavaScript standards while strictly enforcing a minimum Node.js engine requirement of 18.0.0. The package has a focused scope, providing a clear solution for preprocessing CLI arguments that utilize comma-separated values, acting as an essential parsing layer before more complex option handling.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/SBoudrias/cli-list","tags":["javascript"],"install":[{"cmd":"npm install cli-list","lang":"bash","label":"npm"},{"cmd":"yarn add cli-list","lang":"bash","label":"yarn"},{"cmd":"pnpm add cli-list","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package explicitly maintains CommonJS module format since v1.0.0. While `import` may work with bundlers or Node.js's CJS interop for default exports, `require` is the native and most reliable way to consume this package.","wrong":"import list from 'cli-list';","symbol":"list","correct":"const list = require('cli-list');"},{"note":"When using ESM, `cli-list` is consumed as a default export. Ensure your environment or bundler correctly handles CommonJS default exports for ESM `import` statements.","wrong":"import { list } from 'cli-list';","symbol":"list (ESM usage)","correct":"import list from 'cli-list';"}],"quickstart":{"code":"import list from 'cli-list';\nimport minimist from 'minimist'; // minimist needs to be installed via `npm install minimist`\n\n// Simulate process.argv.slice(2) for a test case\n// In a real CLI, you'd use: const args = process.argv.slice(2);\nconst rawCliArgs = ['foo', '--bar,', 'baz', '--qux', 'oof,value'];\n\nconsole.log('Original CLI arguments:', rawCliArgs);\n\n// Split the arguments into sub-arrays based on commas\nconst parsedLists = list(rawCliArgs);\nconsole.log('cli-list parsed lists:', parsedLists);\n// Expected: [['foo', '--bar'], ['baz'], ['--qux', 'oof'], ['value']]\n\n// Process each sub-list using minimist\nconst opts = parsedLists.map(item => minimist(item));\nconsole.log('Minimist parsed options for each list:', opts);\n/*\nExpected Output (opts):\n[\n  { _: [ 'foo' ], bar: true },\n  { _: [ 'baz' ] },\n  { _: [ 'oof' ], qux: true },\n  { _: [ 'value' ] }\n]\n*/","lang":"typescript","description":"Demonstrates how to parse a raw `process.argv` style array with `cli-list` and then further process each resulting sub-array using `minimist`."},"warnings":[{"fix":"Upgrade your Node.js environment to version 18 or higher using tools like `nvm` or your system's package manager.","message":"Version 1.0.0 and above enforce a minimum Node.js engine requirement of `>=18`. Older Node.js versions will fail to install or run the package.","severity":"breaking","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":"For CommonJS projects, use `const list = require('cli-list');`. For ESM projects, ensure your `package.json` has `\"type\": \"module\"` and your bundler/Node.js version supports CJS-ESM interop for default exports, using `import list from 'cli-list';`.","cause":"Attempting to import `cli-list` using `import` syntax in a pure CommonJS environment, or using `require` in a pure ESM environment without proper interop configuration.","error":"Error: Cannot find module 'cli-list'"},{"fix":"Upgrade your Node.js environment to version 18 or higher. Use `node --version` to check your current Node.js version.","cause":"Attempting to install or run `cli-list` version 1.0.0 or newer on a Node.js version older than 18.","error":"npm ERR! code EUNSUPPORTEDENGINE npm ERR! Unsupported engine for cli-list@1.0.0: wanted: {\"node\": \">=18\"} (current: v16.x.x)"}],"ecosystem":"npm","meta_description":null}