Skip to content

feat: TOML configuration management (Phase 5.3)#102

Merged
dc0sk merged 2 commits intomainfrom
phase-5.3-config
May 5, 2026
Merged

feat: TOML configuration management (Phase 5.3)#102
dc0sk merged 2 commits intomainfrom
phase-5.3-config

Conversation

@dc0sk
Copy link
Copy Markdown
Owner

@dc0sk dc0sk commented May 4, 2026

Summary

  • New openpulse-config crate: typed TOML schema covering station, modem, ARDOP, KISS, logging, relay, and trust-store settings; reads ~/.config/openpulse/config.toml with full default fallback
  • openpulse-tnc and openpulse-kisstnc now 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 approach
  • openpulse config init writes a fully-commented TOML template to stdout

Tests

Three inline unit tests in crates/openpulse-config/src/lib.rs:

  • load_defaults_when_no_file — missing file returns built-in defaults
  • cli_override_patternOption<T> override replaces config value, unset flag retains file value
  • missing_fields_get_defaults — partial TOML fills missing fields from defaults via #[serde(default)]

Roadmap

Closes Phase 5.3.

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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-config with typed config structs, defaults, TOML loading, and a commented config init template.
  • Updated openpulse-tnc and openpulse-kisstnc to read shared config and accept CLI overrides for bind/port/mode.
  • Added openpulse config init and 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.

Comment thread crates/openpulse-ardop/src/main.rs Outdated
async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();

let mut cfg = openpulse_config::load().unwrap_or_default();
Comment thread crates/openpulse-kiss/src/main.rs Outdated
async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();

let mut cfg = openpulse_config::load().unwrap_or_default();
Comment thread crates/openpulse-cli/src/main.rs Outdated
Comment on lines +108 to +110
Commands::Config { command } => match command {
cli::ConfigCommands::Init => {
commands::config::run_init()?;
Comment thread crates/openpulse-config/src/lib.rs Outdated
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
@dc0sk dc0sk merged commit 23f8216 into main May 5, 2026
8 checks passed
@dc0sk dc0sk deleted the phase-5.3-config branch May 5, 2026 07:13
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