feat: TOML configuration management (Phase 5.3)#102
Merged
Conversation
New openpulse-config crate reads ~/.config/openpulse/config.toml and provides OpenpulseConfig with typed sections for station, modem, ARDOP, KISS, logging, relay, and trust-store settings. Missing fields fall back to built-in defaults via #[serde(default)]. openpulse-tnc and openpulse-kisstnc now parse clap CLI flags and apply them over the loaded config (CLI flag > config file > built-in default), replacing the previous env-var-only approach. openpulse config init writes a fully-commented TOML template to stdout. Three tests: load_defaults_when_no_file, cli_override_pattern, missing_fields_get_defaults.
There was a problem hiding this comment.
Pull request overview
Adds a new openpulse-config crate to centralize TOML-based runtime configuration and wires the ARDOP/KISS entrypoints plus the CLI to consume it. This fits the codebase by moving ad-hoc per-binary settings into a shared typed config layer and adding a CLI helper to emit a starter config.
Changes:
- Added
openpulse-configwith typed config structs, defaults, TOML loading, and a commentedconfig inittemplate. - Updated
openpulse-tncandopenpulse-kisstncto read shared config and accept CLI overrides for bind/port/mode. - Added
openpulse config initand registered the new crate in the workspace and dependent binaries.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
crates/openpulse-kiss/src/main.rs |
Swaps env-var configuration for shared TOML loading plus CLI overrides in the KISS binary. |
crates/openpulse-kiss/Cargo.toml |
Adds config/clap dependencies for the KISS binary. |
crates/openpulse-config/src/lib.rs |
Introduces the new config schema, defaults, loader, template generator, and unit tests. |
crates/openpulse-config/Cargo.toml |
Defines the new config crate and its parsing/path dependencies. |
crates/openpulse-cli/src/main.rs |
Wires the new config subcommand into CLI dispatch. |
crates/openpulse-cli/src/commands/mod.rs |
Exposes the new config command module. |
crates/openpulse-cli/src/commands/config.rs |
Implements openpulse config init output. |
crates/openpulse-cli/src/cli.rs |
Adds the config init subcommand definition. |
crates/openpulse-cli/Cargo.toml |
Adds the shared config crate dependency to the CLI. |
crates/openpulse-ardop/src/main.rs |
Swaps env-var configuration for shared TOML loading plus CLI overrides in the ARDOP binary. |
crates/openpulse-ardop/Cargo.toml |
Adds config/clap dependencies for the ARDOP binary. |
Cargo.toml |
Registers openpulse-config in the workspace members/dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async fn main() -> anyhow::Result<()> { | ||
| let cli = Cli::parse(); | ||
|
|
||
| let mut cfg = openpulse_config::load().unwrap_or_default(); |
| async fn main() -> anyhow::Result<()> { | ||
| let cli = Cli::parse(); | ||
|
|
||
| let mut cfg = openpulse_config::load().unwrap_or_default(); |
Comment on lines
+108
to
+110
| Commands::Config { command } => match command { | ||
| cli::ConfigCommands::Init => { | ||
| commands::config::run_init()?; |
| fn cli_override_pattern() { | ||
| // CLI flag > config > default: simulate by loading config then applying | ||
| // an Option<T> override, the pattern used by TNC binaries. | ||
| let path = std::env::temp_dir().join("openpulse_config_override_test.toml"); |
- Propagate config load errors in TNC binaries instead of silently falling back to defaults; operators see misconfiguration at startup - Short-circuit `openpulse config init` before PTT/hardware setup so it can never fail due to unreachable rigctld/serial port - Use PID-qualified temp file names in config unit tests to prevent collisions under concurrent cargo test runs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
openpulse-configcrate: typed TOML schema covering station, modem, ARDOP, KISS, logging, relay, and trust-store settings; reads~/.config/openpulse/config.tomlwith full default fallbackopenpulse-tncandopenpulse-kisstncnow accept clap CLI flags (--cmd-port,--data-port,--mode,--bind/--port) that override config file values (precedence: CLI flag > config file > built-in default), replacing the previous env-var-only approachopenpulse config initwrites a fully-commented TOML template to stdoutTests
Three inline unit tests in
crates/openpulse-config/src/lib.rs:load_defaults_when_no_file— missing file returns built-in defaultscli_override_pattern—Option<T>override replaces config value, unset flag retains file valuemissing_fields_get_defaults— partial TOML fills missing fields from defaults via#[serde(default)]Roadmap
Closes Phase 5.3.