Skip to content

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

@chriscalo

Description

@chriscalo

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions