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

Bug: Optional arguments make null values #4

Open
denizdogan opened this issue Feb 10, 2023 · 0 comments
Open

Bug: Optional arguments make null values #4

denizdogan opened this issue Feb 10, 2023 · 0 comments

Comments

@denizdogan
Copy link

From the Clay source code:

If the optional argument was passed, it will be present
at key name in the object returned from parse or run.
Otherwise, the object will not contain the key name.

However, it seems that the value does appear, with null as its value:

// reproduce_null.ts
import * as c from "https://deno.land/x/clay@v0.2.5/mod.ts"
console.log(
  new c.Command("tell me your name")
    .optional(
      c.string,
      "name",
      { flags: ["n", "name"], description: "the name" },
    ).run(),
)

Output:

$ deno run -A ./reproduce_null.ts -h
tell me your name

USAGE:
	 [OPTIONS]

OPTIONS:
	-n, --name <STRING>  the name

$ deno run -A ./reproduce_null.ts -n Bob
{ name: "Bob" }

$ deno run -A ./reproduce_null.ts
{ name: null }
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

1 participant