From 8ad4b04ae208e84b2ebba1600f014f677b18985c Mon Sep 17 00:00:00 2001 From: zhifengle Date: Tue, 21 Feb 2023 11:22:17 +0800 Subject: [PATCH] fixed: txt file is None --- src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index f582b07..24ec393 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,9 +31,18 @@ async fn main() -> anyhow::Result<()> { RSS_JSON.get_or_init(|| matches.get_one::("rss").map(|p| p.clone())); if let Some(("magnet", matches)) = matches.subcommand() { + let link = matches.get_one::("link").cloned(); let txt = matches.get_one::("txt").cloned(); let cid = matches.get_one::("cid").cloned(); - let magnets = get_magnet_list_by_txt(&txt.unwrap())?; + let mut magnets: Vec = Vec::new(); + if txt.is_some() { + magnets = get_magnet_list_by_txt(&txt.unwrap())?; + } else if link.is_some() { + magnets.push(link.unwrap()); + } else { + eprintln!("magnet link or txt file is required"); + std::process::exit(1); + } if let Err(err) = execute_magnets_task(&magnets, cid).await { eprintln!("{}", err); std::process::exit(1);