structopt-toml
structopt-toml copied to clipboard
Doesn't work with enums (subcommands), only uses values from toml file, not from CLI
Hi, thanks for this crate, its premise seems very useful :)
I'm running into an issue though:
from_args_with_toml doesn't seem to overwrite toml-specified field values with cli-specified values when the field occurs within an enum variant that represents a #[structopt(subcommand)], e.g.:
#[derive(Debug, Deserialize, StructOpt, StructOptToml)]
#[structopt(setting(AppSettings::DeriveDisplayOrder))]
struct Args {
#[structopt(subcommand)]
cmd: Command,
}
#[derive(Debug, Deserialize, StructOpt)]
enum Command {
Foo {
#[structopt(short, long, default_value = "0")]
#[serde(default)]
bar: usize,
},
}
It always uses the toml-specified value for bar, ignoring the cli-specified value for `bar!
Also if the cmd is not toml-specified but cli-specified, it returns an error saying that cmd is missing:
missing field
cmdat line 1 column 1
Ideally it would merge both toml and CLI values before checking if something is missing. And CLI-specified values for a field should take priority over toml-specified values.