@dim.iliev/arguments-parser
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Parse arguments string reliably

@dim.iliev/arguments-parser

arguments-parser helps when you need more than just an array of string.

Examples

parse('--author John Doe --message "Hello World Now" -dip')
// Output:
["--author", "John Doe", "--message", '"Hello World Now"', "-dip"];

Parsing grouped short tags

Use breakShortTags to ungroup words like -dip into an array of short tags. It also takes extra care if you have words like -t-g, so you get ['-t', '-g'] and not ['-t', '--', '-g'] which could be cause issues.

Example

const result = parse('--author John Doe --message "Hello World Now" -dip')
// Output:
["--author", "John Doe", "--message", '"Hello World Now"', "-dip"]

breakShortTags(result)
// Output:
[... '"Hello World Now"', "-d", "-i", "-p"]

Package Sidebar

Install

npm i @dim.iliev/arguments-parser

Weekly Downloads

0

Version

1.0.2

License

GPL-3.0-or-later

Unpacked Size

67.1 kB

Total Files

39

Last publish

Collaborators

  • dim.iliev