diff --git a/crates/servicepoint/examples/announce.rs b/crates/servicepoint/examples/announce.rs index ff95479..bb287b4 100644 --- a/crates/servicepoint/examples/announce.rs +++ b/crates/servicepoint/examples/announce.rs @@ -6,16 +6,26 @@ use servicepoint::{CharGrid, Command, Connection, Cp437Grid, Origin}; #[derive(Parser, Debug)] struct Cli { - #[arg(short, long, default_value = "localhost:2342")] + #[arg( + short, + long, + default_value = "localhost:2342", + help = "Address of the display" + )] destination: String, - #[arg(short, long, num_args = 1.., value_delimiter = '\n')] + #[arg(short, long, num_args = 1.., value_delimiter = '\n', + help = "Text to send - specify multiple times for multiple lines")] text: Vec, - #[arg(short, long, default_value_t = true)] + #[arg( + short, + long, + default_value_t = true, + help = "Clear screen before sending text" + )] clear: bool, } -/// example: `cargo run -- --text "Hallo, -/// CCCB"` +/// example: `cargo run -- --text "Hallo" --text "CCCB"` fn main() { let mut cli = Cli::parse(); if cli.text.is_empty() { @@ -31,11 +41,7 @@ fn main() { .expect("sending clear failed"); } - let text = cli.text.iter().fold(String::new(), move |str, line| { - let is_first = str.is_empty(); - str + if is_first { "" } else { "\n" } + line - }); - + let text = cli.text.join("\n"); let grid = CharGrid::from(&*text); let cp437_grid = Cp437Grid::from(&grid);