-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Description
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
--helpis 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]Metadata
Metadata
Assignees
Labels
No labels