Skip to content

Use default values for properties missing from --settings file#125

Open
AmadeusW wants to merge 1 commit into
sameer:mainfrom
AmadeusW:useDefaultsForMissingSettings
Open

Use default values for properties missing from --settings file#125
AmadeusW wants to merge 1 commit into
sameer:mainfrom
AmadeusW:useDefaultsForMissingSettings

Conversation

@AmadeusW

@AmadeusW AmadeusW commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Use default values for properties missing from --settings file.

This allows for a minimal settings file, such as

{
  "conversion": {
    "feedrate": 4500
  },
  "postprocess": {
    "newline_before_comment": true
  }
}

Comment thread cli/src/main.rs
let settings = {
let mut settings = if let Some(path) = opt.settings {
serde_json::from_reader(File::open(path)?)?
let defaults = serde_json::to_value(Settings::default()).unwrap();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I thought this was already possible, an easier way to do this might be to apply serde(default) to the settings struct itself

https://serde.rs/attr-default.html

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

Successfully merging this pull request may close these issues.

2 participants