yargs/yargs

feature request: implies function. also naming

Open

#1,322 创建于 2019年3月20日

在 GitHub 查看
 (7 评论) (2 反应) (0 负责人)JavaScript (10,829 star) (1,053 fork)batch import
Help Wantedfeature request

描述

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.

贡献者指南