Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:add local task scoping for option() instead of global only mode #504

Open
Hotell opened this issue Jan 14, 2021 · 0 comments
Open

feat:add local task scoping for option() instead of global only mode #504

Hotell opened this issue Jan 14, 2021 · 0 comments

Comments

@Hotell
Copy link

Hotell commented Jan 14, 2021

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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant