Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options' defaults not used when using command with init function #138

Open
barbu110 opened this issue Feb 20, 2019 · 3 comments
Open

Options' defaults not used when using command with init function #138

barbu110 opened this issue Feb 20, 2019 · 3 comments

Comments

@barbu110
Copy link

Hello!

First of all, I'd like to say I really like args. It has a few things it's not doing correctly right now, but it's going on a great path.

I created an executable, let's call it myexec:

args.options([{
  name: 'target',
  default: 'dev',
  description: '...',
}]);

args.command('cmd', 'description', (name, sub, options) => {
  console.log(options);
});

Running it goes as follows:

$ ./myexec cmd
{}

The options object should contain the default value of target and it's missing. I think this is a bad problem unless a simple workaround exists. What do you think?

@ntwcklng
Copy link
Collaborator

ntwcklng commented Mar 2, 2019

Hey @barbu110,
the correct property for defining a default value is defaultValue. You've used default.
Can you try again and tell us if this fixed your issue?

@ntwcklng
Copy link
Collaborator

ping @barbu110

@RickeyWard
Copy link

even though his example is wrong, he's correct. This though seems to be by design

  // If sub command is defined, run it
  if (defined) {
    this.runCommand(defined, optionList)
    return {}
  }

  // Hand back list of options
  return optionList

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants