yargs/yargs

feature request: implies function. also naming

开放

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

 (7 条评论) (2 个反应) (0 位负责人)JavaScript (1,053 个派生)batch import
Help Wantedfeature request

仓库指标

星标
 (10,829 个星标)
PR 合并指标
 (平均合并 113天 19小时) (30 天内合并 11 个 PR)

描述

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.

贡献者指南