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(()) } }