Skip to content

boolean silently converts string to true #39

@tttp

Description

@tttp

Hi,

me again, in my quest to idiot proof the cli ;)

so I have two params, one foo and one bar

const argv = require("minimist")(process.argv.slice(2), {
  string: ["foo"],
  boolean: ["bar"]
});

if I run it with

--foo alice --bar bob

I get

  • argv.foo = alice
  • argv.bar=true
  • argv._ = ["bob"]

as expected

however, if I run it with

--foo=alice --bar=bob

I get

  • argv.foo = alice
  • argv.bar=true
  • argv._ = []

so a --bar=string is silently converted into --bar = true

is there an option to catch these conversions ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedpull requests welcomequestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions