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

Doesn't work with enums (subcommands), only uses values from toml file, not from CLI #68

Open
Boscop opened this issue Dec 19, 2022 · 0 comments

Comments

@Boscop
Copy link

Boscop commented Dec 19, 2022

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 cmd at 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.

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