{"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,"search_vec":"'0.10.0':88 '2020':103 '5':110 'abandon':95 'ago':112 'allow':43 'altern':37 'appear':92 'approach':143 'arg':3 'argument':17,29,60,63,65,127 'argv':22 'array':24 'beyond':133 'boolean':72 'categor':58 'come':129 'command':14,32 'command-line-lik':13 'commit':99 'convent':28 'current':84 'data':67 'design':10 'develop':116 'distinguish':25 'driven':141 'express':41 'extract':142 'flag':71,73 'flexibl':138 'howev':89 'indic':113 'input':49 'intern':42 'javascript':8,144 'json':75 'key':68,80 'last':98 'latest':106 'leverag':39 'like':16,31,74 'line':15 'made':100 'mainten':118 'might':128 'npm':107 'ongo':115 'pair':70,82 'param':79 'pars':12,59 'parser':4,30,52 'particular':122 'posit':62 'process':46 'process.argv':134 'project':91 'publish':108 'raw':47,64 'regex':140 'regex-driven':139 'regular':40 'requir':136 'scenario':125 'septemb':102 'sourc':132 'stabl':85 'string':20,48 'style':23 'suit':123 'support':56 'tool':120 'tradit':51 'typic':53 'unlik':35 'util':9 'valu':69,81 'vari':131 'version':86 'warg':1,5 'wrong':2 'x':77 'yarg':34 'year':111","created_at":"2026-04-21T19:19:09.116453+00:00","updated_at":"2026-04-21T19:19:09.116453+00:00","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","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/tacoss/wargs","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/wargs","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-20","install_tag":null}}