microsoft/just

bug: task help generation via option() doesn't work

Hotell opened this issue · 2 comments

Repro

const { task, logger, option, argv } = require('just-task');

option('name', {describe: 'user name or something'});

task('blimey', 'An exclamation of surprise.', function() {
  logger.info(`blimey! ${argv().name}`);
});

Actual behaviour

Basically --help output always invokes yargs default help command.

just --help

image

just blimey --help

image

Expected behaviour

just blimey --help

Options:
  --name    user name or something                                                 [string]
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]

option() as a mechanism is a poor choice for providing command line arguments, as then all arguments defined with it will be global to all tasks. It would be much nicer if I could define options per task:

const { task, logger, option, argv } = require('just-task');

option('name', {describe: 'user name or something'});

task('blimey', 'An exclamation of surprise.', function() {
  logger.info(`blimey! ${argv().name}`);
});

task('something', 'This task does not use arguments', function() {
    logger.info('I do not use name, yet the help text shows it as a valid argument')
})

@Tattoo

I'd say your comment is probably not related to this issue. Pls check #504 . thx