util: add tokens to parseArgs
Offer additional meta-data for building custom and additional behaviour on top of parseArgs
.
parseArgs
supports the primary goal of a useful CLI parser for direct use, but is not offering much for the secondary goal of a basis for building richer functionality, or for customising the behaviour.
@bakkot proposed returning additional meta-data, such as reporting indexes. We have developed that idea into optionally returning a tokens
structure with parsing meta-data in https://github.com/pkgjs/parseargs/pull/129 with input from @aaronccasanova, @bcoe, and @ljharb.
The returned fields are a pragmatic mix of information useful to an author for custom behaviours or fancy error messages. The tokens are used internally by parseArgs
for generating the returned values
and positionals
and performing error detection, using the same meta-data now available to callers. The downstream PR includes some example files of add-on processing: https://github.com/pkgjs/parseargs/pull/129
Edit: fixed link to downstream PR.