You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means the flag is None if the user doesn't provide it to the CLI, and is Some(true) if user provides --flag and is Some(false) if user provides --flag=false.
The idea is that I want None to mean a default value of true.
Now I want to merge a Toml provider with this Serialize provider, with the CLI options taking precedence (I use admerge because I also have Vecs in my data which should be merged):
let temp:Args = Figment::new().admerge(Toml::file("myfile.toml")).admerge(Serialized::defaults(Args::parse())).extract()?;let config:Config = temp.into();
My problem
The problem is that if I set in my TOML flag = false and then provide no flag to the CLI, I would want the final value to be Some(false), but admerge updates the value for flag to be None even if the Toml said false. This means my final Config value is true because that's the default for None.
Is there a way to merge the CLI struct but no overwrite the previous value (from toml) if it's None?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a
clapitem which looks like so:This means the flag is
Noneif the user doesn't provide it to the CLI, and isSome(true)if user provides--flagand isSome(false)if user provides--flag=false.The idea is that I want
Noneto mean a default value oftrue.Now I have my final config object:
Now I want to merge a
Tomlprovider with thisSerializeprovider, with the CLI options taking precedence (I useadmergebecause I also haveVecs in my data which should be merged):My problem
The problem is that if I set in my TOML
flag = falseand then provide no flag to the CLI, I would want the final value to beSome(false), butadmergeupdates the value forflagto beNoneeven if the Toml saidfalse. This means my finalConfigvalue istruebecause that's the default forNone.Is there a way to merge the CLI struct but no overwrite the previous value (from toml) if it's
None?Beta Was this translation helpful? Give feedback.
All reactions