]> code.octet-stream.net Git - hashgood/commitdiff
Remove oddball paste feature
authorThomas Karpiniec <tom.karpiniec@outlook.com>
Sat, 7 Dec 2024 00:02:25 +0000 (13:02 +1300)
committerThomas Karpiniec <tom.karpiniec@outlook.com>
Sat, 7 Dec 2024 00:02:25 +0000 (13:02 +1300)
Cargo.lock
Cargo.toml
src/display.rs
src/main.rs
src/verify.rs

index 1e727f810133ac2ae64920b5d26d7fe9df903138..71019d1b691c7a080b3830bafeacc1e4fca704e4 100644 (file)
@@ -1,6 +1,6 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
-version = 3
+version = 4
 
 [[package]]
 name = "ansi_term"
@@ -22,24 +22,12 @@ dependencies = [
  "winapi",
 ]
 
-[[package]]
-name = "autocfg"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
-
 [[package]]
 name = "bitflags"
 version = "1.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
 
-[[package]]
-name = "block"
-version = "0.1.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
-
 [[package]]
 name = "block-buffer"
 version = "0.10.4"
@@ -70,30 +58,6 @@ dependencies = [
  "vec_map",
 ]
 
-[[package]]
-name = "clipboard-win"
-version = "3.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9fdf5e01086b6be750428ba4a40619f847eb2e95756eee84b18e06e5f0b50342"
-dependencies = [
- "lazy-bytes-cast",
- "winapi",
-]
-
-[[package]]
-name = "copypasta"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "133fc8675ee3a4ec9aa513584deda9aa0faeda3586b87f7f0f2ba082c66fb172"
-dependencies = [
- "clipboard-win",
- "objc",
- "objc-foundation",
- "objc_id",
- "smithay-clipboard",
- "x11-clipboard",
-]
-
 [[package]]
 name = "cpufeatures"
 version = "0.2.12"
@@ -123,21 +87,6 @@ dependencies = [
  "crypto-common",
 ]
 
-[[package]]
-name = "dlib"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
-dependencies = [
- "libloading",
-]
-
-[[package]]
-name = "downcast-rs"
-version = "1.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
-
 [[package]]
 name = "generic-array"
 version = "0.14.7"
@@ -148,21 +97,10 @@ dependencies = [
  "version_check",
 ]
 
-[[package]]
-name = "gethostname"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e"
-dependencies = [
- "libc",
- "winapi",
-]
-
 [[package]]
 name = "hashgood"
 version = "0.4.0"
 dependencies = [
- "copypasta",
  "hex",
  "md-5",
  "sha1",
@@ -195,12 +133,6 @@ version = "0.4.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
 
-[[package]]
-name = "lazy-bytes-cast"
-version = "5.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10257499f089cd156ad82d0a9cd57d9501fa2c989068992a97eb3c27836f206b"
-
 [[package]]
 name = "lazy_static"
 version = "1.5.0"
@@ -213,31 +145,6 @@ version = "0.2.155"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
 
-[[package]]
-name = "libloading"
-version = "0.8.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d"
-dependencies = [
- "cfg-if",
- "windows-targets",
-]
-
-[[package]]
-name = "log"
-version = "0.4.22"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
-
-[[package]]
-name = "malloc_buf"
-version = "0.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
-dependencies = [
- "libc",
-]
-
 [[package]]
 name = "md-5"
 version = "0.10.6"
@@ -248,77 +155,6 @@ dependencies = [
  "digest",
 ]
 
-[[package]]
-name = "memmap2"
-version = "0.5.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "memoffset"
-version = "0.6.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
-dependencies = [
- "autocfg",
-]
-
-[[package]]
-name = "nix"
-version = "0.24.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
-dependencies = [
- "bitflags",
- "cfg-if",
- "libc",
- "memoffset",
-]
-
-[[package]]
-name = "objc"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
-dependencies = [
- "malloc_buf",
-]
-
-[[package]]
-name = "objc-foundation"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
-dependencies = [
- "block",
- "objc",
- "objc_id",
-]
-
-[[package]]
-name = "objc_id"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
-dependencies = [
- "objc",
-]
-
-[[package]]
-name = "once_cell"
-version = "1.19.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
-
-[[package]]
-name = "pkg-config"
-version = "0.3.30"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
-
 [[package]]
 name = "proc-macro-error"
 version = "1.0.4"
@@ -361,12 +197,6 @@ dependencies = [
  "proc-macro2",
 ]
 
-[[package]]
-name = "scoped-tls"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
-
 [[package]]
 name = "sha1"
 version = "0.10.6"
@@ -389,40 +219,6 @@ dependencies = [
  "digest",
 ]
 
-[[package]]
-name = "smallvec"
-version = "1.13.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
-
-[[package]]
-name = "smithay-client-toolkit"
-version = "0.16.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "870427e30b8f2cbe64bf43ec4b86e88fe39b0a84b3f15efd9c9c2d020bc86eb9"
-dependencies = [
- "bitflags",
- "dlib",
- "lazy_static",
- "log",
- "memmap2",
- "nix",
- "pkg-config",
- "wayland-client",
- "wayland-cursor",
- "wayland-protocols",
-]
-
-[[package]]
-name = "smithay-clipboard"
-version = "0.6.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a345c870a1fae0b1b779085e81b51e614767c239e93503588e54c5b17f4b0e8"
-dependencies = [
- "smithay-client-toolkit",
- "wayland-client",
-]
-
 [[package]]
 name = "strsim"
 version = "0.8.0"
@@ -518,79 +314,6 @@ version = "0.9.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
 
-[[package]]
-name = "wayland-client"
-version = "0.29.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715"
-dependencies = [
- "bitflags",
- "downcast-rs",
- "libc",
- "nix",
- "scoped-tls",
- "wayland-commons",
- "wayland-scanner",
- "wayland-sys",
-]
-
-[[package]]
-name = "wayland-commons"
-version = "0.29.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902"
-dependencies = [
- "nix",
- "once_cell",
- "smallvec",
- "wayland-sys",
-]
-
-[[package]]
-name = "wayland-cursor"
-version = "0.29.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661"
-dependencies = [
- "nix",
- "wayland-client",
- "xcursor",
-]
-
-[[package]]
-name = "wayland-protocols"
-version = "0.29.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6"
-dependencies = [
- "bitflags",
- "wayland-client",
- "wayland-commons",
- "wayland-scanner",
-]
-
-[[package]]
-name = "wayland-scanner"
-version = "0.29.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53"
-dependencies = [
- "proc-macro2",
- "quote",
- "xml-rs",
-]
-
-[[package]]
-name = "wayland-sys"
-version = "0.29.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4"
-dependencies = [
- "dlib",
- "lazy_static",
- "pkg-config",
-]
-
 [[package]]
 name = "winapi"
 version = "0.3.9"
@@ -616,15 +339,6 @@ dependencies = [
  "windows-sys",
 ]
 
-[[package]]
-name = "winapi-wsapoll"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1eafc5f679c576995526e81635d0cf9695841736712b4e892f87abbe6fed3f28"
-dependencies = [
- "winapi",
-]
-
 [[package]]
 name = "winapi-x86_64-pc-windows-gnu"
 version = "0.4.0"
@@ -703,46 +417,3 @@ name = "windows_x86_64_msvc"
 version = "0.52.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
-
-[[package]]
-name = "x11-clipboard"
-version = "0.7.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "980b9aa9226c3b7de8e2adb11bf20124327c054e0e5812d2aac0b5b5a87e7464"
-dependencies = [
- "x11rb",
-]
-
-[[package]]
-name = "x11rb"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507"
-dependencies = [
- "gethostname",
- "nix",
- "winapi",
- "winapi-wsapoll",
- "x11rb-protocol",
-]
-
-[[package]]
-name = "x11rb-protocol"
-version = "0.10.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67"
-dependencies = [
- "nix",
-]
-
-[[package]]
-name = "xcursor"
-version = "0.3.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a0ccd7b4a5345edfcd0c3535718a4e9ff7798ffc536bb5b5a0e26ff84732911"
-
-[[package]]
-name = "xml-rs"
-version = "0.8.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193"
index 4eb291bee6d09df003fd6d7bbf3a773f507a5bf9..d40dfe1f31c7795dc6d753ee8956bb4532bb7637 100644 (file)
@@ -16,10 +16,3 @@ termcolor = "1.4"
 sha2 = "0.10"
 sha1 = "0.10"
 md-5 = "0.10"
-
-[dependencies.copypasta]
-version = "0.8.1"
-optional = true
-
-[features]
-paste = ["copypasta"]
index 2cc940adca4d8883274ec1663c13d6a89d3b3b2a..b886a111f909f5705140226cce010e4330ee2ba2 100644 (file)
@@ -70,9 +70,6 @@ fn write_source(
         VerificationSource::CommandArgument => {
             writeln!(&mut stdout, "command line argument")?;
         }
-        VerificationSource::Clipboard => {
-            writeln!(&mut stdout, "pasted from clipboard")?;
-        }
         VerificationSource::RawFile(raw_path) => match raw_path.as_str() {
             "-" => {
                 writeln!(&mut stdout, "from standard input")?;
index b611b14c9c6ed6f04a52c7921ed37241fd109679..ff5a00cbf83d5d64861c8f3deaab1a6be84e6c42 100644 (file)
@@ -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,19 +37,6 @@ pub struct Opt {
     hash: Option<String>,
 }
 
-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 {
@@ -79,7 +61,6 @@ impl Algorithm {
 #[derive(Debug, PartialEq)]
 pub enum VerificationSource {
     CommandArgument,
-    Clipboard,
     RawFile(String),
     DigestsFile(String),
 }
@@ -205,15 +186,11 @@ fn hashgood() -> Result<(), Box<dyn Error>> {
 /// Parse the command line options and check for ambiguous or inconsistent settings
 fn get_verified_options() -> Result<Opt, String> {
     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)")
         }
index 0f2d1d88325de4e19b90da50479bd75b6fd81b52..e655d1a5052024a33d82079098f3edc82614be9c 100644 (file)
@@ -2,8 +2,6 @@ use super::{
     Algorithm, CandidateHash, CandidateHashes, Hash, MatchLevel, MessageLevel, Opt, Verification,
     VerificationSource,
 };
-#[cfg(feature = "paste")]
-use copypasta::{ClipboardContext, ClipboardProvider};
 use std::fs::File;
 use std::io;
 use std::io::prelude::*;
@@ -16,8 +14,6 @@ use std::path::Path;
 pub fn get_candidate_hashes(opt: &Opt) -> Result<Option<CandidateHashes>, String> {
     if let Some(hash_string) = &opt.hash {
         return Ok(Some(get_by_parameter(hash_string)?));
-    } else if opt.get_paste() {
-        return Ok(Some(get_from_clipboard()?));
     } else if let Some(hash_file) = &opt.hash_file {
         return Ok(Some(get_from_file(hash_file)?));
     }
@@ -40,39 +36,6 @@ fn get_by_parameter(param: &str) -> Result<CandidateHashes, String> {
     })
 }
 
-/// Generate a candidate hash from the system clipboard, or throw an error.
-fn get_from_clipboard() -> Result<CandidateHashes, String> {
-    #[cfg(feature = "paste")]
-    {
-        let mut ctx: ClipboardContext = match ClipboardContext::new() {
-            Ok(ctx) => ctx,
-            Err(e) => return Err(format!("Error getting system clipboard: {}", e)),
-        };
-
-        let possible_hash = match ctx.get_contents() {
-            Ok(value) => value,
-            Err(e) => format!("Error reading from clipboard: {}", e),
-        };
-
-        let bytes = hex::decode(&possible_hash)
-            .map_err(|_| "Clipboard contains invalid or truncated hex".to_owned())?;
-        let alg = Algorithm::from_len(bytes.len())?;
-        let candidate = CandidateHash {
-            filename: None,
-            bytes,
-        };
-        Ok(CandidateHashes {
-            alg,
-            hashes: vec![candidate],
-            source: VerificationSource::Clipboard,
-        })
-    }
-    #[cfg(not(feature = "paste"))]
-    {
-        Err("Paste not implemented".to_owned())
-    }
-}
-
 /// Generate a candidate hash from the digests file specified (could be "-" for STDIN), or throw an error.
 fn get_from_file(path: &Path) -> Result<CandidateHashes, String> {
     // Get a reader for either standard input or the chosen path