Closed halfzebra closed 2 years ago
structopt can't do this but clap can.
StructOpt only accepts a literal value for default_value
and so it can't be set to a function call. structopt is in maintenance mode and clap3's derive
feature is the "next version".
Clap has a default_value_t
attribute that does accept Rust expressions and could be used to solve this. The old default_value
attribute was a weird mixture of working with str
and working with your native type. These concepts were split and default_value
only works with pre-parsed str
and we now have default_value_t
which works with native types. See also the derive tutorial.
@epage Thanks for clarifying this!
It took me a few minutes to change the program to use clap
instead. :+1:
Hello, thanks for working on structopt! :raised_hands:
I'd like to have the current timestamp assigned as
default_value
but I haven't found an elegant solution to this.Here's my current code:
Is there a better way for doing this?