mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
fix: preserve comments in config.yml when saving
Co-authored-by: aider (gemini/gemini-2.5-pro-preview-05-06) <aider@aider.chat>
This commit is contained in:
parent
9a97027870
commit
68dc16344a
2 changed files with 26 additions and 2 deletions
|
|
@ -78,8 +78,28 @@ impl Default for Config {
|
|||
}
|
||||
|
||||
pub fn save_config(path: &str, config: &Config) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let contents = serde_yaml::to_string(config)?;
|
||||
fs::write(path, contents)?;
|
||||
let mut s = String::new();
|
||||
s.push_str("# Hardware offset in milliseconds for correcting capture latency.\n");
|
||||
s.push_str(&format!("hardwareOffsetMs: {}\n\n", config.hardware_offset_ms));
|
||||
|
||||
s.push_str("# Enable automatic clock synchronization.\n");
|
||||
s.push_str("# When enabled, the system will perform an initial full sync, then periodically\n");
|
||||
s.push_str("# nudge the clock to keep it aligned with the LTC source.\n");
|
||||
s.push_str(&format!("autoSyncEnabled: {}\n\n", config.auto_sync_enabled));
|
||||
|
||||
s.push_str("# Default nudge in milliseconds for adjtimex control.\n");
|
||||
s.push_str(&format!("defaultNudgeMs: {}\n\n", config.default_nudge_ms));
|
||||
|
||||
s.push_str("# Time-turning offsets. All values are added to the incoming LTC time.\n");
|
||||
s.push_str("# These can be positive or negative.\n");
|
||||
s.push_str("timeturnerOffset:\n");
|
||||
s.push_str(&format!(" hours: {}\n", config.timeturner_offset.hours));
|
||||
s.push_str(&format!(" minutes: {}\n", config.timeturner_offset.minutes));
|
||||
s.push_str(&format!(" seconds: {}\n", config.timeturner_offset.seconds));
|
||||
s.push_str(&format!(" frames: {}\n", config.timeturner_offset.frames));
|
||||
s.push_str(&format!(" milliseconds: {}\n", config.timeturner_offset.milliseconds));
|
||||
|
||||
fs::write(path, s)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ hardwareOffsetMs: 20
|
|||
# nudge the clock to keep it aligned with the LTC source.
|
||||
autoSyncEnabled: false
|
||||
|
||||
# Default nudge in milliseconds for adjtimex control.
|
||||
defaultNudgeMs: 2
|
||||
|
||||
# Time-turning offsets. All values are added to the incoming LTC time.
|
||||
# These can be positive or negative.
|
||||
timeturnerOffset:
|
||||
|
|
@ -54,6 +57,7 @@ timeturnerOffset:
|
|||
minutes: 0
|
||||
seconds: 0
|
||||
frames: 0
|
||||
milliseconds: 0
|
||||
"#;
|
||||
|
||||
/// If no `config.yml` exists alongside the binary, write out the default.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue