shitbox/hashbox/commands/mod.rs
2023-02-13 10:32:36 -05:00

38 lines
998 B
Rust

use shitbox::Cmd;
mod b2sum;
mod hashbox;
mod md5sum;
mod sha1sum;
mod sha224sum;
mod sha256sum;
mod sha384sum;
mod sha512sum;
/// Parses a string into a command to run
#[must_use]
#[allow(clippy::box_default)]
pub fn get(name: &str) -> Option<Box<dyn Cmd>> {
match name {
"b2sum" => Some(Box::new(b2sum::B2sum::default())),
"hashbox" => Some(Box::new(hashbox::Hashbox::default())),
"md5sum" => Some(Box::new(md5sum::Md5sum::default())),
"sha1sum" => Some(Box::new(sha1sum::Sha1sum::default())),
"sha224sum" => Some(Box::new(sha224sum::Sha224sum::default())),
"sha256sum" => Some(Box::new(sha256sum::Sha256sum::default())),
"sha384sum" => Some(Box::new(sha384sum::Sha384sum::default())),
"sha512sum" => Some(Box::new(sha512sum::Sha512sum::default())),
_ => None,
}
}
pub static COMMANDS: [&str; 7] = [
"b2sum",
"md5sum",
"sha1sum",
"sha224sum",
"sha256sum",
"sha384sum",
"sha512sum",
];