first commit

This commit is contained in:
2022-10-11 16:48:15 +02:00
commit 9097a18926
18 changed files with 2636 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
use argh::FromArgs;
use crate::Error;
use crate::action::ActionExec;
use crate::config::Config;
use crate::utils::torrent_to_magnet;
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "magnet")]
/// produce magnet link from torrent file
pub struct MagnetAction {
#[argh(positional)]
/// the magnet torrent file to parse
torrent: String,
}
impl ActionExec for MagnetAction {
fn exec(&self, _config: &Config) -> Result<(), Error> {
if self.torrent.starts_with("magnet:") {
println!("{}", &self.torrent);
} else {
println!("{}", torrent_to_magnet(&self.torrent));
}
Ok(())
}
}