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"
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"

View File

@@ -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"

View File

@@ -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<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
#[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,