dthree / dthree/vorpal

Option function and default parameter is not executed

Open
#52 9 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted question
Dominant language
JavaScript
Stars
5.6k
Forks
278
PR merge metrics
No merged PRs in 30d

Description

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?

``` js
#! /usr/bin/env node

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

cli
.command('test')
.description('A test')
.option('--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);
```

``` sh
$ ./cli test
URL: undefined
```

``` sh
$ ./cli test --url other.url
URL: other.url
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.