2. parseArgs(argv)
Parses an array of CLI arguments into positional and named arguments.
Example:
1node cli.js foo bar --count 3 --verbose true
Output:
1{2 positional: ["foo", "bar"],3 named: { count: 3, verbose: true }4}
Behavior:
--key valuebecomesnamed[key] = value.- Multiple values after a flag become an array.
- Flag with no value →
true. - Single-value arrays are simplified to a single value.