feat:add local task scoping for option() instead of global only mode
Hotell opened this issue · 0 comments
Hotell commented
Currently option()
works on global level (one singleton via an object).
While this behaviour might be ok for task or two, one will start having issue in bigger project.
To support good DX it should be able to locally scope option per task, which would have following outcomes:
- properly generate CLI flags when
--help
is invoked on particular task - properly apply yargs parser on particular task
New Contrived API proposal
const { task, logger, option, argv } = require('just-task');
task('blimey', 'An exclamation of surprise.', function() {
logger.info(`blimey! ${argv().name}`);
})
.option('name', {describe: 'user name or something'})
task('greet', 'say hi.', function() {
logger.info(`say hi! ${argv().greeting} ${argv().who} !`);
})
.option('greeting', {describe: 'what greeting should be used'})
.option('who', {describe: 'who should we greet?'})
which would work like following:
just blimey --help
Options:
--name user name or something [string]
--help Show help [boolean]
--version Show version number [boolean]
just greet --help
Options:
--greeting what greeting should be used [string]
--who who should we greet [string]
--help Show help [boolean]
--version Show version number [boolean]