X-Git-Url: https://code.octet-stream.net/hashgood/blobdiff_plain/5e06e2eba2c37e443d7cada780ca2837951d8a94..5d1d9862b731b309b546dffdbd4fe3984210eda6:/src/main.rs diff --git a/src/main.rs b/src/main.rs index b611b14..cc9c570 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,11 +20,6 @@ const EXIT_MISMATCH: i32 = 2; #[derive(StructOpt)] #[structopt(name = "hashgood")] pub struct Opt { - /// Read the hash from the clipboard - #[cfg(feature = "paste")] - #[structopt(short = "p", long = "paste")] - paste: bool, - /// Disable ANSI colours in output #[structopt(short = "C", long = "no-colour")] no_colour: bool, @@ -42,25 +37,13 @@ pub struct Opt { hash: Option, } -impl Opt { - fn get_paste(&self) -> bool { - #[cfg(feature = "paste")] - { - self.paste - } - #[cfg(not(feature = "paste"))] - { - false - } - } -} - /// Types of supported digest algorithm #[derive(Debug, PartialEq, Copy, Clone)] pub enum Algorithm { Md5, Sha1, Sha256, + Sha512, } impl Algorithm { @@ -70,6 +53,7 @@ impl Algorithm { 16 => Ok(Algorithm::Md5), 20 => Ok(Algorithm::Sha1), 32 => Ok(Algorithm::Sha256), + 64 => Ok(Algorithm::Sha512), _ => Err(format!("Unrecognised hash length: {} bytes", len)), } } @@ -79,7 +63,6 @@ impl Algorithm { #[derive(Debug, PartialEq)] pub enum VerificationSource { CommandArgument, - Clipboard, RawFile(String), DigestsFile(String), } @@ -187,7 +170,12 @@ fn hashgood() -> Result<(), Box> { } else { // If no candidate, calculate all three common digest types for output let hashes = calculate::create_digests( - &[Algorithm::Md5, Algorithm::Sha1, Algorithm::Sha256], + &[ + Algorithm::Md5, + Algorithm::Sha1, + Algorithm::Sha256, + Algorithm::Sha512, + ], input, )?; for (alg, bytes) in hashes { @@ -205,15 +193,11 @@ fn hashgood() -> Result<(), Box> { /// Parse the command line options and check for ambiguous or inconsistent settings fn get_verified_options() -> Result { let opt = Opt::from_args(); - let hash_methods = - opt.hash.is_some() as i32 + opt.get_paste() as i32 + opt.hash_file.is_some() as i32; + let hash_methods = opt.hash.is_some() as i32 + opt.hash_file.is_some() as i32; if hash_methods > 1 { if opt.hash.is_some() { eprintln!("* specified as command line argument"); } - if opt.get_paste() { - eprintln!("* paste from clipboard (-p)") - } if opt.hash_file.is_some() { eprintln!("* check hash from file (-c)") }