{"_id":"string-argv@0.4.0","bugs":{"url":"https://github.com/mccormicka/string-argv/issues"},"dist":{"shasum":"773a4a666b6b0925ea5d90e58ce40d5a90bba230","tarball":"http://registry-npm.ywwl.com/string-argv/download/string-argv-0.4.0.tgz","fileCount":6,"integrity":"sha512-UOtaksJ3SK3KLHba2i9I27fvuZNfBlImDP5wKsCOxCDMRDNxlipCe8rmnUAaDpqlQ93upnA0SzF2pjWhttozSA==","signatures":[{"sig":"MEUCIQD8mkHb4uPugITgdLCYByCjPhjT0UWYzyUX97rF3EQihwIgSwGiH/k1qoXcNE2yyWjqBFwXG83H/zs0FtJzFN1Oez8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDKGr/be8PFhb43XmPuUXkVPf6kuO+W3MHSLCpGnwN0dwIhAKMbZYKCHu1RfqkjOeJWXVnsPtHrFX/OJr7DpZOXScpF"}],"unpackedSize":10659,"size":4436,"noattachment":false,"key":"/string-argv/-/string-argv-0.4.0.tgz"},"main":"./index.js","name":"string-argv","type":"module","types":"index.d.ts","author":{"name":"Anthony McCormick","email":"anthony.mccormick@gmail.com"},"engines":{"node":">=16.20.0"},"exports":{".":{"types":"./index.d.ts","import":"./index.js"}},"gitHead":"d9b225a7b9c2a3aba46682caa6bf3af31e6e3a10","license":"MIT","scripts":{"test":"npm run build & jasmine --config=test/config.json","build":"tsc -p .","test:no-build":"jasmine --config=test/config.json","prepublishOnly":"npm test"},"version":"0.4.0","_npmUser":{"name":"cellule","email":"mike.ferris@hotmail.com"},"homepage":"https://github.com/mccormicka/string-argv","keywords":["argv"],"repository":{"url":"git+https://github.com/mccormicka/string-argv.git","type":"git"},"_npmVersion":"11.19.0","description":"string-argv parses a string into an argument array to mimic process.argv. This is useful when testing Command Line Utilities that you want to pass arguments to.","directories":{},"maintainers":[{"name":"mccormicka","email":"anthony.mccormick@gmail.com"},{"name":"cellule","email":"mike.ferris@hotmail.com"}],"_nodeVersion":"26.8.1","contributors":[{"name":"Michael Ferris","email":"mike.ferri@hotmail.com"}],"_hasShrinkwrap":false,"devDependencies":{"jasmine":"^4.4.0","typescript":"^7.0.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/string-argv_0.4.0_1790645570762_0.054861571757504946"},"readme":"\n# What is it?\n`string-argv` parses a string into an argument array to mimic `process.argv`.\nThis is useful when testing Command Line Utilities that you want to pass arguments to and is the opposite of what the other argv utilities do.\n\n# Installation\n\n```\nnpm install string-argv --save\n```\n\n# Requirements\n\nRequires Node.js `>=16.20.0`.\n\nThis package is ESM-only (`\"type\": \"module\"`). Use `import`, not `require()`:\n\n```js\nimport stringArgv from 'string-argv';\n```\n\nTypeScript 7 requires Node.js >=16.20, and the single ESM build targets\nES2022, so 16.20.0 is the minimum supported version.\n\n# Usage\n\n```ts\n// Typescript\nimport stringArgv from 'string-argv';\n\nconst args = stringArgv(\n  '-testing test -valid=true --quotes \"test quotes\" \"nested \\'quotes\\'\" --key=\"some value\" --title=\"Peter\\'s Friends\"',\n  'node',\n  'testing.js'\n);\n\nconsole.log(args);\n```\n\n```js\n// Javascript (ESM)\nimport { parseArgsStringToArgv } from 'string-argv';\n\nvar args = parseArgsStringToArgv(\n    '-testing test -valid=true --quotes \"test quotes\" \"nested \\'quotes\\'\" --key=\"some value\" --title=\"Peter\\'s Friends\"',\n    'node',\n    'testing.js'\n);\n\nconsole.log(args);\n/** output\n[ 'node',\n  'testing.js',\n  '-testing',\n  'test',\n  '-valid=true',\n  '--quotes',\n  'test quotes',\n  'nested \\'quotes\\'',\n  '--key=some value',\n  '--title=Peter\\'s Friends' ]\n  **/\n```\n\n## params\n\n__required__: __arguments__ String: arguments that you would normally pass to the command line.\n\n__optional__: __environment__ String: Adds to the environment position in the argv array. If ommitted then there is no need to call argv.split(2) to remove the environment/file values. However if your cli.parse method expects a valid argv value then you should include this value.\n\n__optional__: __file__ String: file that called the arguments. If omitted then there is no need to call argv.split(2) to remove the environment/file values. However if your cli.parse method expects a valid argv value then you should include this value.\n\n## Parsing behavior (bash-compatible quoting)\n\nQuoting follows bash word-splitting rules: `'` and `\"` group text into a single\nargument, adjacent quoted and unquoted segments are concatenated, and the quote\ncharacters themselves are removed. Whitespace separates arguments only when it\nappears outside of quotes.\n\n```\n--foo=\"bar\"'baz'                    -> [--foo=barbaz]\na\" b\"                                -> [a b]\n\"a\"b                                 -> [ab]\njake run:silent[\"echo 1\"][\"echo 2\"]  -> [jake, run:silent[echo 1][echo 2], --trace]\n--name='Phil Taylor'                 -> [--name=Phil Taylor]\n--title=\"Peter's Friends\"            -> [--title=Peter's Friends]\n```\n\nA quote of the opposite kind inside quotes is kept literally\n(`--name='Phil \"The Power\" Taylor'` -> `--name=Phil \"The Power\" Taylor`),\nand empty quotes produce an empty argument (`\"\"` -> `[\"\"]`).\n\nKnown differences from bash:\n- backslash escapes are not processed\n- `$variables`, globs and other expansions are left literal\n- an unclosed quote consumes the rest of the input instead of raising a syntax error\n","publish_time":1790645570877,"_cnpm_publish_time":1790645570877,"dist-tags":{"latest":"0.4.0"}}