diff --git a/.zpkg.toml b/.zpkg.toml new file mode 100644 index 0000000..12087d1 --- /dev/null +++ b/.zpkg.toml @@ -0,0 +1,49 @@ +[package] +org = "led-dynamo" +name = "leddy-cli" +version = "0.1.0" +description = "Command-line client for publishing, clearing, inspecting, and automating Leddy displays" +license = "MIT" +keywords = ["led-matrix", "cli", "automation", "iot", "rust"] +language = "rust" + +[package.repository] +vcs = "git" +url = "https://github.com/led-dynamo/leddy-cli" + +[dependencies] +"led-dynamo/leddy-interfaces" = "^0.1.0" +"led-dynamo/leddy-lib" = "^0.1.0" +"led-dynamo/leddy-clients" = "^0.1.0" + +[build] +command = "cargo build --release" +outputs = ["target/release/leddy-cli"] + +[bin] +leddy = "target/release/leddy-cli" + +[publish] +include_readme = true +tag_format = "v{version}" +smoke_test = "test -x \"$ZED_PKG_TEST_TARGET/target/release/leddy-cli\" && \"$ZED_PKG_TEST_TARGET/target/release/leddy-cli\" --help" +exclude = [ + ".env", + ".env.*", + ".vendor/.zed/**", + ".zed/**", + ".zed-pack/**", + "target/**", + "**/*.log", +] + +[publish.native] +registry = "crates-io" +package = "leddy-cli" + +[install] +adapter = "none" +dir = ".vendor/.zed" + +[scripts] +test = "cargo test --all-targets" diff --git a/src/main.rs b/src/main.rs index b5ef5f9..e1d98fd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,26 +39,42 @@ async fn main() -> Result<(), Box> { let client = LeddyClient::new(arguments.api_url); match arguments.command { - Command::Send { text, speed, direction } => { + Command::Send { + text, + speed, + direction, + } => { let message = MessageEnvelope { id: format!("cli-{}", now_unix_ms()), text, speed_pixels_per_second: speed, - direction: match direction { Direction::Left => ScrollDirection::Left, Direction::Right => ScrollDirection::Right }, + direction: match direction { + Direction::Left => ScrollDirection::Left, + Direction::Right => ScrollDirection::Right, + }, repeat: RepeatMode::Forever, issued_at_unix_ms: now_unix_ms(), }; message.validate()?; let width = leddy_lib::content_width(&message.text); let status = client.publish_message(&message).await?; - println!("accepted {} ({} rendered pixels, HTTP {})", message.id, width, status); + println!( + "accepted {} ({} rendered pixels, HTTP {})", + message.id, width, status + ); } Command::Clear => println!("clear accepted (HTTP {})", client.clear().await?), - Command::Health => { client.health().await?; println!("ok"); } + Command::Health => { + client.health().await?; + println!("ok"); + } } Ok(()) } fn now_unix_ms() -> u64 { - SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_millis() as u64 + SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_millis() as u64 }