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
+28
View File
@@ -0,0 +1,28 @@
use argh::FromArgs;
use crate::Error;
use crate::action::ActionExec;
use crate::config::Config;
use crate::utils::{magnet_hash, torrent_hash};
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "hash")]
/// get infohash from magnet/torrent
pub struct HashAction {
#[argh(positional)]
/// the magnet link or torrent file to parse
torrent: String,
}
impl ActionExec for HashAction {
fn exec(&self, _config: &Config) -> Result<(), Error> {
// TODO errors
let hash = if self.torrent.starts_with("magnet:") {
magnet_hash(&self.torrent)
} else {
torrent_hash(&self.torrent)
};
println!("{}", hash);
Ok(())
}
}