dthree/vorpal

Option function and default parameter is not executed

Open

#52 创建于 2015年12月2日

在 GitHub 查看
 (9 评论) (0 反应) (0 负责人)JavaScript (313 fork)batch import
enhancementhelp wantedquestion

仓库指标

Star
 (5,609 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

In source diving the arguments passed to command.option, it appears that it accepts a 3rd and 4th parameter for defining a function and default value for the option, but it appears that these aren't actually being executed. In this test case, I was unable to get a default value or have the function execute. Am I doing something wrong, or is this just not supported yet?

#! /usr/bin/env node

let Vorpal = require('vorpal');
let cli = new Vorpal();

cli
  .command('test')
  .description('A test')
  .option('--url <url>', 'Some url', function(val) { cli.log('VALUE!', value); }, 'http://some.url')
  .action(function(args, done) {
    this.log('URL:', args.options.url);
    done();
  });

cli.parse(process.argv);
$ ./cli test
URL: undefined
$ ./cli test --url other.url
URL: other.url

贡献者指南