iffy / nim-argparse

Argument parsing for Nim
MIT License
120 stars 8 forks source link

Don't convert option values to string #68

Closed floscr closed 2 years ago

floscr commented 2 years ago

Values for options get automatically converted to "" even if the user has not passed any value, this makes it impossible to detect if the user has passed an empty string to the cli.

It would be neat to get a way to access the original Option so we can be more explicit.

Something like this

var p = newParser:
  command("command"):
    option("--foo")
    run:
      assert: opts.fooOpt == none[string]
iffy commented 2 years ago

I like the idea of adding an Opt (or _opt) suffix to the variable name to preserve backward compatibility.

floscr commented 2 years ago

Awesome, thank you! :raised_hands: