I recently switched a project from Structopt to Gumdrop and am generally quite happy with the change. However, one thing I've not been able to figure out how to do is to use a const to define a default value.
Essentially, I define a default port and use this in several places in the code:
/// Constant defining Goose's default port when running a Gaggle.
const DEFAULT_PORT: &str = "5115";
One of the places I was able to use it with structopt was in defining the default value for a couple of run-time configuration options. Is there any way to do this with gumdrop?
For example, if I try this:
/// Sets port Manager listens on
#[options(no_short, default = DEFAULT_PORT, meta = "PORT")]
pub manager_bind_port: u16,
I get the following error:
error: expected literal
--> src/lib.rs:1945:35
|
1945 | #[options(no_short, default = DEFAULT_PORT, meta = "PORT")]
| ^^^^^^^^^^^^
I recently switched a project from Structopt to Gumdrop and am generally quite happy with the change. However, one thing I've not been able to figure out how to do is to use a
constto define adefaultvalue.Essentially, I define a default port and use this in several places in the code:
One of the places I was able to use it with
structoptwas in defining the default value for a couple of run-time configuration options. Is there any way to do this with gumdrop?For example, if I try this:
I get the following error: