fix: improve CLI behavior from testing feedback

Stop a running daemon during uninstall, fuzzy-match cached app names,
and pace remote sequences with a configurable delay so Roku secret
screen sequences behave more reliably.
This commit is contained in:
44r0n7
2026-04-15 12:44:45 -04:00
parent 8bf0a94416
commit 348c2bc9bc
4 changed files with 130 additions and 12 deletions
+9 -1
View File
@@ -25,6 +25,7 @@ use crate::{
const DAEMON_START_WAIT_ATTEMPTS: usize = 20;
const DAEMON_START_WAIT_INTERVAL: Duration = Duration::from_millis(250);
const DEFAULT_REMOTE_SEQUENCE_DELAY_MS: u64 = 200;
/// The tvctl command-line interface.
#[derive(Debug, Parser)]
@@ -182,6 +183,9 @@ pub enum RemoteCommand {
Sequence {
/// Key names such as `home down select`.
keys: Vec<String>,
/// Delay between keys in milliseconds.
#[arg(long, default_value_t = DEFAULT_REMOTE_SEQUENCE_DELAY_MS)]
delay_ms: u64,
},
}
@@ -450,7 +454,7 @@ async fn handle_remote_command(cli: &Cli, command: RemoteCommand) -> Result<(),
let result: ActionResult = parse_response_data(response)?;
render(cli, &result, || result.detail.clone())
}
RemoteCommand::Sequence { keys } => {
RemoteCommand::Sequence { keys, delay_ms } => {
if keys.is_empty() {
return Err(CliError::new(
"At least one key is required for `tvctl remote sequence`.",
@@ -466,6 +470,7 @@ async fn handle_remote_command(cli: &Cli, command: RemoteCommand) -> Result<(),
&DaemonRequest::SendSequence {
device: cli.device.clone(),
keys: parsed,
delay_ms,
},
)
.await?;
@@ -730,6 +735,9 @@ async fn daemon_install(cli: &Cli) -> Result<(), CliError> {
}
async fn daemon_uninstall(cli: &Cli) -> Result<(), CliError> {
if daemon_status_payload().await.is_some() {
daemon_stop(cli).await?;
}
let unit_path = systemd_unit_path();
let _ = run_systemctl(&["--user", "disable", "--now", "tvctld.service"]).await;
match fs::remove_file(&unit_path).await {