From 9cff696dec73c7821884e2836bad0524e4c2284a Mon Sep 17 00:00:00 2001 From: structix Date: Wed, 2 Nov 2022 18:33:30 +0100 Subject: [PATCH] Update switches --- Cargo.lock | 29 +++++++++++++++++++++++++---- Cargo.toml | 1 + src/main.rs | 14 ++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e391b8..9bc3e9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,9 +92,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" dependencies = [ "iana-time-zone", + "js-sys", "num-integer", "num-traits", "serde", + "time 0.1.44", + "wasm-bindgen", "winapi", ] @@ -368,7 +371,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -529,7 +532,7 @@ checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.36.1", ] @@ -576,6 +579,7 @@ name = "obs-cli" version = "0.1.0" dependencies = [ "anyhow", + "chrono", "clap", "confy", "obws", @@ -600,7 +604,7 @@ dependencies = [ "serde_with", "sha2", "thiserror", - "time", + "time 0.3.15", "tokio", "tokio-tungstenite", "tracing", @@ -845,7 +849,7 @@ dependencies = [ "serde", "serde_json", "serde_with_macros", - "time", + "time 0.3.15", ] [[package]] @@ -962,6 +966,17 @@ dependencies = [ "syn", ] +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + [[package]] name = "time" version = "0.3.15" @@ -1148,6 +1163,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 3048d0e..f205a07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,5 @@ anyhow = "1.0" clap = { version = "4.0.18", features = ["derive"] } confy = "0.5.1" serde = { version = "1.0", features = ["derive"] } +chrono = "0.4.22" diff --git a/src/main.rs b/src/main.rs index 7d2c62a..8141959 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ use clap::Parser; use tokio::time::{sleep_until, Instant, Duration}; use tokio::process::Command; use serde::{Serialize, Deserialize}; +use chrono::NaiveTime; #[tokio::main] async fn main() -> Result<()> { @@ -77,6 +78,11 @@ async fn shutdown() -> Result<(), anyhow::Error> { Ok(()) } +fn parse_time(time: &str) -> Result { + let parsed = NaiveTime::parse_from_str(time, "%H:%M")?; + Ok(parsed) +} + /// obs-cli is a simple cli tool for planned OBS recordings #[derive(Parser, Debug)] @@ -90,6 +96,14 @@ struct Args { #[arg(short, long, default_value_t = 1)] duration_minutes: u64, + /// Define the start time in HH:MM format + #[arg(short, long, default_value_t = String::from("14:00"))] + begin_time: String, + + /// Define the end time in HH:MM format + #[arg(short, long, default_value_t = String::from("14:00"))] + end_time: String, + /// Flag to shutdown the machine after recording. #[arg(short, long, default_value_t = false)] poweroff: bool,