Hyphenated option is not supported (needs docs)
Lets say we have the following file
const { task, option, logger, argv } = require('just-task');
const { spawn } = require('child_process');
option('no-cache', { default: false });
task('sayhello', function() {
logger.info(argv());
});
and we were to run npx just sayhello --no-cache, we will got the following result
[4:17:16 PM] ■ started 'sayhello'
[4:17:16 PM] ■ { _: [ 'sayhello' ],
cache: false,
'no-cache': false,
noCache: false,
'$0': 'node_modules/.bin/just' }
[4:17:16 PM] ■ finished 'sayhello' in 0.01s
if we instead run with npx just sayhello --noCache, it will then registers
[4:20:01 PM] ■ started 'sayhello'
[4:20:01 PM] ■ { _: [ 'sayhello' ],
noCache: true,
'no-cache': true,
'$0': 'node_modules/.bin/just' }
[4:20:01 PM] ■ finished 'sayhello' in 0.01s
It seems this is coming from yargs parser on this issue https://github.com/yargs/yargs-parser/issues/92 which since have been solved in the current version.
Would there be plan to update the yargs dependency in the project to the current version?
It's actually that the word "no" has a special meaning in the yargs world. It indicates the opposite of the flag and would result in a false. Maybe try another set of words in your options?
what about this
$ npx just sayhello --Cache=false
@kenotron thoughts?
Well,I have added the following
option('first-name', { default: 'world' });
and ran the following with the result
$ npx just sayhello --first-name
[4:23:00 PM] ■ started 'sayhello'
[4:23:00 PM] ■ { _: [ 'sayhello' ],
'first-name': true,
firstName: true,
'no-cache': false,
noCache: false,
'$0': 'node_modules/.bin/just' }
[4:23:00 PM] ■ finished 'sayhello' in 0.01s
so yes, it seems the word no itself has certain significance
Wow, I'm running into the same issue. My options is called no-fork. If I change it to xy-fork it works. no seems to have a special meaning that interferes with the parsing.
yeah, this is the same rule as what yargs provides. You can look at what all the options allowed are: http://yargs.js.org/docs/#api-optionkey-opt
I need to document this :P
Documentation needed (reopened)
Issues seem to have gone stale.