microsoft / microsoft/just

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

Open
#504 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2k
Forks
97
PR merge metrics
No merged PRs in 30d

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 --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]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the task, option(), and argv() entry points and how the yargs parser currently obtains global options. Done means options can be scoped to an individual task, with task-specific --help flags and parsing matching the proposed blimey and greet examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.