{"id":16268,"library":"wargs","title":"Wargs - Wrong Args Parser","description":"Wargs is a JavaScript utility designed for parsing command-line-like arguments from both strings and `argv`-style arrays, distinguishing itself from conventional argument parsers like `commander` or `yargs`. Unlike most alternatives, it leverages regular expressions internally, allowing it to process raw string inputs which traditional parsers typically do not support. It categorizes parsed arguments into `_` (positional arguments), `raw` (arguments after `--`), `data` (key=value pairs), `flags` (boolean flags like `--json` or `-x`), and `params` (key:value pairs). The current stable version is 0.10.0, however, the project appears to be abandoned with the last commit made in September 2020 and the latest npm publish being 5 years ago, indicating no ongoing development or maintenance. This tool is particularly suited for scenarios where arguments might come from varied sources beyond `process.argv` and require a flexible, regex-driven extraction approach.","status":"abandoned","version":"0.10.0","language":"javascript","source_language":"en","source_url":"https://github.com/tacoss/wargs","tags":["javascript"],"install":[{"cmd":"npm install wargs","lang":"bash","label":"npm"},{"cmd":"yarn add wargs","lang":"bash","label":"yarn"},{"cmd":"pnpm add wargs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally for parsing standard short and long flags.","package":"getopts","optional":false}],"imports":[{"note":"Wargs is a default export. Named imports will result in a TypeError.","wrong":"import { wargs } from 'wargs';","symbol":"wargs","correct":"import wargs from 'wargs';"},{"note":"CommonJS usage for the default export. Destructuring is incorrect.","wrong":"const { wargs } = require('wargs');","symbol":"wargs","correct":"const wargs = require('wargs');"}],"quickstart":{"code":"import wargs from 'wargs';\n\nconst strInput = '/ _csrf=`token` --json accept:\"text/plain; charset=utf8\" -- x foo:bar';\nconst arrayInput = ['/', '_csrf=`token`', '--json', 'accept:text/plain; charset=utf8', '--', 'x', 'foo:bar'];\n\nconsole.log('--- Parsing String Input ---');\nconst parsedFromString = wargs(strInput, { camelCase: true });\nconsole.log('Parsed Object:', parsedFromString);\nconsole.log('Positional arguments (_):', parsedFromString._);\nconsole.log('Raw arguments (raw):', parsedFromString.raw);\nconsole.log('Data (key=value):', parsedFromString.data);\nconsole.log('Flags (--flag, -f):', parsedFromString.flags);\nconsole.log('Parameters (key:value):', parsedFromString.params);\n\nconsole.log('\\n--- Parsing Array Input ---');\nconst parsedFromArray = wargs(arrayInput, { format: v => String(v).toUpperCase() });\nconsole.log('Parsed Object:', parsedFromArray);\nconsole.log('Positional arguments (_):', parsedFromArray._);\nconsole.log('Raw arguments (raw):', parsedFromArray.raw);\nconsole.log('Data (key=value):', parsedFromArray.data);\nconsole.log('Flags (--flag, -f):', parsedFromArray.flags);\nconsole.log('Parameters (key:value):', parsedFromArray.params);\n","lang":"javascript","description":"Demonstrates parsing both string and array inputs, and accessing the different argument categories (`_`, `raw`, `data`, `flags`, `params`) along with options like `camelCase` and `format`."},"warnings":[{"fix":"Thoroughly review the documentation and examples to understand how `wargs` processes arguments and maps them to its distinct output properties.","message":"Wargs is explicitly designed as a 'wrong args parser' and deviates significantly from common CLI parsing libraries like `minimist` or `yargs`. Its regex-based approach and unique categorization of arguments (`data` for `key=value` vs. `params` for `key:value`) requires careful understanding of its output structure.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consider migrating to an actively maintained argument parsing library for new or critical projects. If usage is essential, be aware of potential unpatched vulnerabilities or incompatibilities with newer Node.js versions.","message":"The `wargs` package appears to be abandoned. The last commit to its GitHub repository was in September 2020, and the latest version (0.10.0) was published 5 years ago on npm. This means there is no active development, bug fixes, or security patches, making it unsuitable for new projects or critical applications.","severity":"deprecated","affected_versions":">=0.10.0"},{"fix":"Create a `wargs.d.ts` file with appropriate type declarations (e.g., `declare module 'wargs' { function wargs(input: string | string[], options?: any): { _: string[]; raw: string[]; data: { [key: string]: string }; flags: { [key: string]: boolean }; params: { [key: string]: string } }; export default wargs; }`) or cast the return value to `any`.","message":"Wargs does not ship with TypeScript type definitions. Developers using TypeScript will need to create their own declaration files (`.d.ts`) or use `declare module 'wargs';` to avoid type errors, losing the benefits of strong typing.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Use a default import: `import wargs from 'wargs';`","cause":"Attempting to use `wargs` with named import syntax (`import { wargs } from 'wargs'`) when it is a default export.","error":"TypeError: (0 , wargs__WEBPACK_IMPORTED_MODULE_0__.wargs) is not a function"},{"fix":"Use the direct `require()` assignment: `const wargs = require('wargs');`","cause":"Attempting to destructure `wargs` from `require()` in CommonJS (`const { wargs } = require('wargs')`) when it is a default export.","error":"TypeError: wargs is not a function"},{"fix":"Refer to the `wargs` documentation carefully. `data` collects `key=value` pairs, while `params` collects `key:value` pairs. Adjust your input or access the correct output property accordingly.","cause":"Misunderstanding the distinction between `data` (for `key=value` syntax) and `params` (for `key:value` syntax) in `wargs`'s output structure.","error":"Arguments not parsed as expected (e.g., 'key=value' in 'params' instead of 'data')"}],"ecosystem":"npm"}