yargs/yargs

feature request: implies function. also naming

Ouverte

#1 322 ouverte le 20 mars 2019

 (7 commentaires) (2 réactions) (0 personne assignée)JavaScript (1 053 forks)batch import
Help Wantedfeature request

Métriques du dépôt

Stars
 (10 829 étoiles)
Métriques de merge PR
 (Merge moyen 113j 19h) (11 PRs mergées en 30 j)

Description

I have a case where option x is a "choices" option allowing ['foo', 'bar', 'baz']. Option y implies x === 'foo'.

Current workaround is using check().

Maybe an API like this:

yargs.option('a')
  .choices('a', ['foo', 'bar', 'baz'])
  .option('b')
  .implies('b', argv => argv.a === 'foo');

Also, "implies" seems like a misnomer to me. Putting my logician's hat on, if m implies n, then if m is true, n should also be true, right? I would then expect "implies" to set m if I supplied n. Granted, the types/values of m and n could be completely different, and I'm not asking for this functionality, but perhaps "depends on" or "requires option" would be more appropriate.

Guide contributeur