Skip to content

yargs 17: option not listed in help output when coerced #1909

@gr2m

Description

@gr2m
// index.js
import yargs from "yargs";
import { hideBin } from "yargs/helpers";

const argv = yargs(hideBin(process.argv))
  .option("option1", {
    describe: "option1 description",
    type: "string",
    demandOption: true,
  })
  .option("option2", {
    describe: "option2 description",
    type: "string",
    demandOption: true,
  })
  .coerce("option2", () => undefined).argv;

Result with [email protected]

$ node index.js --help
Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --option1  option1 description                             [string] [required]

Result with [email protected]

$ node index.js --help
Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --option1  option1 description                             [string] [required]
  --option2  option2 description                             [string] [required]

Reproducible test case: https://runkit.com/gr2m/yargs-yargs-1909

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions