refactor: clean up daemon and CLI duplication

Reduce repeated adapter dispatch, CLI action rendering, and config save
flows while keeping the current Roku behavior and docs aligned with the
known secret-menu limitations.
This commit is contained in:
44r0n7
2026-04-15 15:25:49 -04:00
parent 0095462216
commit 45620b1ab5
9 changed files with 802 additions and 237 deletions
+31
View File
@@ -18,6 +18,8 @@ pub struct TvctlConfig {
pub discovery: DiscoveryConfig,
/// Default-device settings.
pub devices: DeviceConfig,
/// Remote input behavior.
pub remote: RemoteConfig,
/// Developer tooling toggles.
pub dev: DevConfig,
}
@@ -28,6 +30,7 @@ impl Default for TvctlConfig {
daemon: DaemonConfig::default(),
discovery: DiscoveryConfig::default(),
devices: DeviceConfig::default(),
remote: RemoteConfig::default(),
dev: DevConfig::default(),
}
}
@@ -79,6 +82,11 @@ impl TvctlConfig {
self.discovery.timeout_secs.to_string(),
),
("devices.default", self.devices.default.clone()),
("remote.roku_key_mode", self.remote.roku_key_mode.clone()),
(
"remote.roku_press_duration_ms",
self.remote.roku_press_duration_ms.to_string(),
),
("dev.enabled", self.dev.enabled.to_string()),
("dev.roku_username", self.dev.roku_username.clone()),
("dev.roku_password", self.dev.roku_password.clone()),
@@ -102,6 +110,10 @@ impl TvctlConfig {
"discovery.interval_secs" => self.discovery.interval_secs = parse_value(key, value)?,
"discovery.timeout_secs" => self.discovery.timeout_secs = parse_value(key, value)?,
"devices.default" => self.devices.default = value.to_string(),
"remote.roku_key_mode" => self.remote.roku_key_mode = value.to_string(),
"remote.roku_press_duration_ms" => {
self.remote.roku_press_duration_ms = parse_value(key, value)?
}
"dev.enabled" => self.dev.enabled = parse_bool(key, value)?,
"dev.roku_username" => self.dev.roku_username = value.to_string(),
"dev.roku_password" => self.dev.roku_password = value.to_string(),
@@ -169,6 +181,25 @@ pub struct DeviceConfig {
pub default: String,
}
/// Remote input behavior.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(default)]
pub struct RemoteConfig {
/// Roku key delivery mode: `keypress` or `keydown_up`.
pub roku_key_mode: String,
/// How long a Roku key stays pressed before `keyup`, in milliseconds.
pub roku_press_duration_ms: u64,
}
impl Default for RemoteConfig {
fn default() -> Self {
Self {
roku_key_mode: "keypress".to_string(),
roku_press_duration_ms: 75,
}
}
}
/// Developer tooling toggles.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(default)]