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

Option with default value and global: true doesn't work #208

Open
chriscalo opened this issue May 5, 2021 · 0 comments
Open

Option with default value and global: true doesn't work #208

chriscalo opened this issue May 5, 2021 · 0 comments
Assignees

Comments

@chriscalo
Copy link
Contributor

chriscalo commented May 5, 2021

Describe the bug
Option with default value and global: true doesn't work.

To Reproduce
Steps to reproduce the behavior:

#!/usr/bin/env node
const { program } = require("@caporal/core");

program.option("--env", "Set env vars", {
  global: true, // this causes the problem
  default: "dev",
});

program.action(({ options }) => {
  console.log(options);
});

program.run();

Expected behavior
When no value is provided, I expect the default value of the option to be set:

node index.js
{ env: true }

But this doesn't happen when global: true is set.

Actual behavior
The options object is empty:

node index.js
{ }

Environment informations (please complete the following information):

  • OS: Mac
  • OS version: 11.2.2
  • Shell: bash
  • Caporal version: 2.0.2

Additional context
The meaning of global: true is in the docs, but it isn't discussed in any detail, so I may be misinterpreting its purpose.

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

2 participants