feat: replace prompt with inform (fire-and-forget), logs default 20 lines
This commit is contained in:
parent
d2f77f8054
commit
af0b6b5ddb
5 changed files with 51 additions and 13 deletions
|
|
@ -275,8 +275,8 @@ enum Commands {
|
|||
device: String,
|
||||
},
|
||||
|
||||
/// Show a MessageBox asking the user to do something
|
||||
Prompt {
|
||||
/// Show a notification to the user (fire-and-forget, no response needed)
|
||||
Inform {
|
||||
/// Device label
|
||||
device: String,
|
||||
/// Message to display
|
||||
|
|
@ -342,7 +342,7 @@ enum Commands {
|
|||
/// Device label
|
||||
device: String,
|
||||
/// Number of lines
|
||||
#[arg(long, default_value = "100")]
|
||||
#[arg(long, default_value = "20")]
|
||||
lines: u32,
|
||||
},
|
||||
}
|
||||
|
|
@ -537,7 +537,7 @@ fn main() {
|
|||
println!("All windows minimized on {}.", device);
|
||||
}
|
||||
|
||||
Commands::Prompt {
|
||||
Commands::Inform {
|
||||
device,
|
||||
message,
|
||||
title,
|
||||
|
|
@ -547,19 +547,14 @@ fn main() {
|
|||
if let Some(t) = title {
|
||||
body["title"] = json!(t);
|
||||
}
|
||||
let data = req(
|
||||
req(
|
||||
&cfg,
|
||||
"POST",
|
||||
&format!("/devices/{}/prompt", device),
|
||||
&format!("/devices/{}/inform", device),
|
||||
Some(body),
|
||||
30,
|
||||
10,
|
||||
);
|
||||
let answer = data["answer"].as_str().unwrap_or("");
|
||||
if !answer.is_empty() {
|
||||
println!("{}", answer);
|
||||
} else {
|
||||
println!("Prompt confirmed.");
|
||||
}
|
||||
println!("User informed on {}.", device);
|
||||
}
|
||||
|
||||
Commands::Run {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue