WHAT
Allow dependent scripts to (optionally) specify how flag input should be parsed by providing callback
functions at instantiation time.
Callback functions would be applied to the raw CLI input, and the resulting values would be exposed to the dependent script as normal (eg. via cli.flags
).
For example:
meow( {
flags: {
unicorn: {
alias: 'u',
callback: value => {
// Perform transformation and return result.
}
}
}
} );
WHY
This would be useful for cases where the underlying API requires an array value for a specific option.
Rather than updating the API to support/parse both arrays and strings, the transformation could be handled directly in the CLI layer.
For example:
meow( {
flags: {
excludes: {
callback: value => {
return value.split(',');
}
}
}
} );
$ <cli command> <input> --excludes logs,temp,dist // [ 'logs', 'temp', 'dist' ]
HOW
I've stubbed out an initial implementation and test on my fork, which I'd be happy to submit for review.
NOTES
I stumbled on Issue #44 after digging into this proposed update. I'm not sure what the state of that issue is, but it looks like there's at least some overlap in terms of functionality.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too