如何根据另一个参数的响应使参数成为强制性参数?

时间:2019-01-17 10:53:00

标签: javascript node.js command-line-interface command-line-arguments yargs

我想基于第一个请求的参数将参数设为强制性。我在命令行上询问涉及哪个平台(“ local”,“ dev”,“ preprod”,“ prod”),如果提供的参数是“ local”,那么我想询问第二个强制性参数(“ trigramme” )。我还没有找到解决方法。

预先感谢您的帮助。

const argv = yargs
    .usage('Usage: $0 <command> [options]')
    .option('platform', {
        alias: 'p',
        choices: ["local", "dev", "preprod", "prod"],
        demandOption: true,
        describe: 'Platform to set',
        requiresArg: true,
    })
    .option('trigramme', {
        alias: 't',
        describe: 'Fill a trigramme for the local platform',
    })
    .argv;

0 个答案:

没有答案