Update switches

This commit is contained in:
2022-11-02 18:33:30 +01:00
parent 0e3ce083a5
commit 9cff696dec
3 changed files with 40 additions and 4 deletions

29
Cargo.lock generated
View File

@@ -92,9 +92,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
dependencies = [ dependencies = [
"iana-time-zone", "iana-time-zone",
"js-sys",
"num-integer", "num-integer",
"num-traits", "num-traits",
"serde", "serde",
"time 0.1.44",
"wasm-bindgen",
"winapi", "winapi",
] ]
@@ -368,7 +371,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
] ]
[[package]] [[package]]
@@ -529,7 +532,7 @@ checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
"wasi", "wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.36.1", "windows-sys 0.36.1",
] ]
@@ -576,6 +579,7 @@ name = "obs-cli"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono",
"clap", "clap",
"confy", "confy",
"obws", "obws",
@@ -600,7 +604,7 @@ dependencies = [
"serde_with", "serde_with",
"sha2", "sha2",
"thiserror", "thiserror",
"time", "time 0.3.15",
"tokio", "tokio",
"tokio-tungstenite", "tokio-tungstenite",
"tracing", "tracing",
@@ -845,7 +849,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"serde_with_macros", "serde_with_macros",
"time", "time 0.3.15",
] ]
[[package]] [[package]]
@@ -962,6 +966,17 @@ dependencies = [
"syn", "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]] [[package]]
name = "time" name = "time"
version = "0.3.15" version = "0.3.15"
@@ -1148,6 +1163,12 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 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]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.0+wasi-snapshot-preview1" version = "0.11.0+wasi-snapshot-preview1"

View File

@@ -12,4 +12,5 @@ anyhow = "1.0"
clap = { version = "4.0.18", features = ["derive"] } clap = { version = "4.0.18", features = ["derive"] }
confy = "0.5.1" confy = "0.5.1"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
chrono = "0.4.22"

View File

@@ -5,6 +5,7 @@ use clap::Parser;
use tokio::time::{sleep_until, Instant, Duration}; use tokio::time::{sleep_until, Instant, Duration};
use tokio::process::Command; use tokio::process::Command;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use chrono::NaiveTime;
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
@@ -77,6 +78,11 @@ async fn shutdown() -> Result<(), anyhow::Error> {
Ok(()) Ok(())
} }
fn parse_time(time: &str) -> Result<NaiveTime, anyhow::Error> {
let parsed = NaiveTime::parse_from_str(time, "%H:%M")?;
Ok(parsed)
}
/// obs-cli is a simple cli tool for planned OBS recordings /// obs-cli is a simple cli tool for planned OBS recordings
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@@ -90,6 +96,14 @@ struct Args {
#[arg(short, long, default_value_t = 1)] #[arg(short, long, default_value_t = 1)]
duration_minutes: u64, 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. /// Flag to shutdown the machine after recording.
#[arg(short, long, default_value_t = false)] #[arg(short, long, default_value_t = false)]
poweroff: bool, poweroff: bool,