diff options
-rw-r--r-- | crates/yt/src/cli.rs | 16 | ||||
-rw-r--r-- | crates/yt/src/main.rs | 19 |
2 files changed, 34 insertions, 1 deletions
diff --git a/crates/yt/src/cli.rs b/crates/yt/src/cli.rs index 3e59c55..f12b58d 100644 --- a/crates/yt/src/cli.rs +++ b/crates/yt/src/cli.rs @@ -280,6 +280,22 @@ pub(crate) struct SharedSelectionCommandArgs { pub(crate) url: Option<Url>, } + +impl SelectCommand { + pub(crate) fn into_shared(self) -> Option<SharedSelectionCommandArgs> { + match self { + SelectCommand::File { .. } + | SelectCommand::Split { .. } + | SelectCommand::Add { .. } => None, + SelectCommand::Watch { shared } + | SelectCommand::Drop { shared } + | SelectCommand::Watched { shared } + | SelectCommand::Url { shared } + | SelectCommand::Pick { shared } => Some(shared), + } + } +} + #[derive(Clone, Debug, Copy)] pub(crate) struct OptionalNaiveDate { pub(crate) date: Option<NaiveDate>, diff --git a/crates/yt/src/main.rs b/crates/yt/src/main.rs index 0926ac7..2331dd7 100644 --- a/crates/yt/src/main.rs +++ b/crates/yt/src/main.rs @@ -131,7 +131,24 @@ async fn main() -> Result<()> { sort_key, sort_mode, } => Box::pin(select::select_split(&app, done, sort_key, sort_mode)).await?, - _ => Box::pin(handle_select_cmd(&app, cmd, None)).await?, + SelectCommand::Add { urls, start, stop } => { + Box::pin(select::cmds::add::add(&app, urls, start, stop)).await?; + } + other => { + let shared = other + .clone() + .into_shared() + .expect("The ones without shared should have been filtered out."); + let hash = shared.hash.realize(&app).await?; + let mut video = hash + .get_with_app(&app) + .await + .expect("The hash was already realized, it should therefore exist"); + + let mut ops = Operations::new("Main: handle select cmd"); + handle_select_cmd(&app, other, &mut video, None, &mut ops).await?; + ops.commit(&app).await?; + } } } Command::Sedowa {} => { |