about summary refs log tree commit diff stats
path: root/src/main.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-10-07 19:41:15 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-10-07 19:41:15 +0200
commit03197cd47ac595dec00ac8c047be0c66b5716a71 (patch)
tree4b04b1d9e1c1f78db22f0172a678d16241ae6391 /src/main.rs
parentfix(cli): Avoid having to interleave `sedowa` with dashes (diff)
downloadyt-03197cd47ac595dec00ac8c047be0c66b5716a71.tar.gz
yt-03197cd47ac595dec00ac8c047be0c66b5716a71.zip
feat(cli): Also add a `dowa` command
This is the same as the `sedowa` command, with the difference that the
`dowa` command does not include the select part.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/main.rs b/src/main.rs
index 0961dd3..3f7e410 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -110,22 +110,12 @@ async fn main() -> Result<()> {
         Command::Sedowa {} => {
             select::select(&app, false, false).await?;
 
-            let max_cache_size = app.config.download.max_cache_size;
-            info!("Max cache size: '{}'", max_cache_size);
-
             let arc_app = Arc::new(app);
-
-            let arc_app_clone = Arc::clone(&arc_app);
-            let download: JoinHandle<Result<()>> = tokio::spawn(async move {
-                download::Downloader::new()
-                    .consume(arc_app_clone, max_cache_size.as_u64())
-                    .await?;
-
-                Ok(())
-            });
-
-            watch::watch(&arc_app).await?;
-            download.await??;
+            dowa(arc_app).await?;
+        }
+        Command::Dowa {} => {
+            let arc_app = Arc::new(app);
+            dowa(arc_app).await?;
         }
         Command::Videos { cmd } => match cmd {
             VideosCommand::List {
@@ -232,3 +222,21 @@ async fn main() -> Result<()> {
 
     Ok(())
 }
+
+async fn dowa(arc_app: Arc<App>) -> Result<()> {
+    let max_cache_size = arc_app.config.download.max_cache_size;
+    info!("Max cache size: '{}'", max_cache_size);
+
+    let arc_app_clone = Arc::clone(&arc_app);
+    let download: JoinHandle<Result<()>> = tokio::spawn(async move {
+        download::Downloader::new()
+            .consume(arc_app_clone, max_cache_size.as_u64())
+            .await?;
+
+        Ok(())
+    });
+
+    watch::watch(&arc_app).await?;
+    download.await??;
+    Ok(())
+}