aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-02-14 16:31:19 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-02-14 16:31:19 +0100
commitceb0ff290707905af56106401b3f2a326971c505 (patch)
tree83f0baf34660aa897f27e0395b46e14e3340653e
parentfeat(yt/select/cmds/add): Support `start` `stop` args (diff)
downloadyt-ceb0ff290707905af56106401b3f2a326971c505.zip
fix(yt/cli): Make most of the arguments to `yt select <cmd> <hash>` optional
In most cases `yt select watch <id>` is enough, but the previous cli specification required you to insert: `[TITLE] [DATE] [PUBLISHER] [DURATION] [URL]`. These are not used (except the `url` command), and thus the cli usage can be greatly improved by allowing the to be empty.
Diffstat (limited to '')
-rw-r--r--yt/src/cli.rs10
-rw-r--r--yt/src/select/cmds/mod.rs8
2 files changed, 11 insertions, 7 deletions
diff --git a/yt/src/cli.rs b/yt/src/cli.rs
index b110772..e95b93f 100644
--- a/yt/src/cli.rs
+++ b/yt/src/cli.rs
@@ -218,15 +218,15 @@ pub struct SharedSelectionCommandArgs {
/// The short extractor hash
pub hash: LazyExtractorHash,
- pub title: String,
+ pub title: Option<String>,
- pub date: OptionalNaiveDate,
+ pub date: Option<OptionalNaiveDate>,
- pub publisher: OptionalPublisher,
+ pub publisher: Option<OptionalPublisher>,
- pub duration: Duration,
+ pub duration: Option<Duration>,
- pub url: Url,
+ pub url: Option<Url>,
}
#[derive(Clone, Debug, Copy)]
pub struct OptionalNaiveDate {
diff --git a/yt/src/select/cmds/mod.rs b/yt/src/select/cmds/mod.rs
index f576241..105569b 100644
--- a/yt/src/select/cmds/mod.rs
+++ b/yt/src/select/cmds/mod.rs
@@ -18,7 +18,7 @@ use crate::{
},
};
-use anyhow::{Context, Result};
+use anyhow::{bail, Context, Result};
mod add;
@@ -50,9 +50,13 @@ pub async fn handle_select_cmd(
}
SelectCommand::Url { shared } => {
+ let Some(url) = shared.url else {
+ bail!("You need to provide a url to `select url ..`")
+ };
+
let mut firefox = std::process::Command::new("firefox");
firefox.args(["-P", "timesinks.youtube"]);
- firefox.arg(shared.url.as_str());
+ firefox.arg(url.as_str());
let _handle = firefox.spawn().context("Failed to run firefox")?;
}
SelectCommand::File { .. } => unreachable!("This should have been filtered out"),