Parses raw CLI argv array into an Args object.
A lightweight, dependency-free alternative to mri/minimist with compatible behavior.
Features:
--flag → {flag: true}--flag value → {flag: 'value'} or {flag: 123} (numeric coercion)--flag=value → equals syntax--flag= → {flag: ''} (empty string, differs from mri which returns true)-f → {f: true} (short flag)-f value → {f: 'value'}-abc → {a: true, b: true, c: true} (combined short flags)-abc value → {a: true, b: true, c: 'value'} (last flag gets value)--no-flag → {flag: false} (negation prefix)-- → stops flag parsing, rest become positionals- Positionals collected in
_ array - Repeated flags become arrays
Intentional differences from mri:
--flag= returns '' (mri returns true)--flag= next returns {flag: '', _: ['next']} (mri takes next as the value)---flag returns {'-flag': true} (mri strips all dashes)['--flag', ''] preserves '' (mri coerces to 0)--__proto__ works as a normal key (mri silently fails)
The returned object uses Object.create(null) to prevent prototype pollution
and allow any key name including __proto__ and constructor.