use clap::ArgMatches; use shitbox::Cmd; mod base32; mod base64; mod basename; mod bootstrap; mod cat; mod chmod; mod chown; mod chroot; mod corebox; mod cp; mod cut; mod date; mod dd; mod df; mod dirname; mod echo; mod expand; mod factor; mod r#false; mod fold; mod getty; mod groups; mod head; mod hostid; mod hostname; mod link; mod ln; mod logname; mod ls; mod mkfifo; mod mknod; mod mktemp; mod mv; mod nologin; mod nproc; mod printenv; mod pwd; mod readlink; mod realpath; mod rev; mod rm; mod rmdir; mod sleep; mod sync; mod touch; mod r#true; mod unlink; mod wc; mod which; mod whoami; mod yes; /// Parses a string into a command to run #[must_use] #[allow(clippy::box_default)] pub fn get(name: &str) -> Option> { match name { "base64" => Some(Box::new(base64::Base64::default())), "base32" => Some(Box::new(base32::Base32::default())), "basename" => Some(Box::new(basename::Basename::default())), "bootstrap" => Some(Box::new(bootstrap::Bootstrap::default())), "chmod" => Some(Box::new(chmod::Chmod::default())), "chgrp" => Some(Box::new(chown::Chgrp::default())), "chown" => Some(Box::new(chown::Chown::default())), "chroot" => Some(Box::new(chroot::Chroot::default())), "corebox" => Some(Box::new(corebox::Corebox::default())), "cut" => Some(Box::new(cut::Cut::default())), "df" => Some(Box::new(df::Df::default())), "dirname" => Some(Box::new(dirname::Dirname::default())), "echo" => Some(Box::new(echo::Echo::default())), "factor" => Some(Box::new(factor::Factor::default())), "false" => Some(Box::new(r#false::False::default())), "fold" => Some(Box::new(fold::Fold::default())), "groups" => Some(Box::new(groups::Groups::default())), "head" => Some(Box::new(head::Head::default())), "hostid" => Some(Box::new(hostid::Hostid::default())), "hostname" => Some(Box::new(hostname::Hostname::default())), "link" => Some(Box::new(link::Link::default())), "ln" => Some(Box::new(ln::Ln::default())), "logname" => Some(Box::new(logname::Logname::default())), "mkfifo" => Some(Box::new(mkfifo::MkFifo::default())), "mknod" => Some(Box::new(mknod::MkNod::default())), "mktemp" => Some(Box::new(mktemp::MkTemp::default())), "nologin" => Some(Box::new(nologin::Nologin::default())), "nproc" => Some(Box::new(nproc::Nproc::default())), "printenv" => Some(Box::new(printenv::Printenv::default())), "pwd" => Some(Box::new(pwd::Pwd::default())), "readlink" => Some(Box::new(readlink::Readlink::default())), "realpath" => Some(Box::new(realpath::Realpath::default())), "rev" => Some(Box::new(rev::Rev::default())), "rm" => Some(Box::new(rm::Rm::default())), "rmdir" => Some(Box::new(rmdir::Rmdir::default())), "sleep" => Some(Box::new(sleep::Sleep::default())), "sync" => Some(Box::new(sync::Sync::default())), "touch" => Some(Box::new(touch::Touch::default())), "true" => Some(Box::new(r#true::True::default())), "unlink" => Some(Box::new(unlink::Unlink::default())), "wc" => Some(Box::new(wc::Wc::default())), "which" => Some(Box::new(which::Which::default())), "whoami" => Some(Box::new(whoami::Whoami::default())), "yes" => Some(Box::new(yes::Yes::default())), _ => None, } } pub static COMMANDS: [&str; 44] = [ "base32", "base64", "basename", "bootstrap", "chgrp", "chmod", "chown", "chroot", "corebox", "cut", "df", "dirname", "echo", "false", "factor", "fold", "groups", "head", "hostid", "hostname", "link", "ln", "logname", "mkfifo", "mknod", "mktemp", "nologin", "nproc", "printenv", "pwd", "readlink", "realpath", "rev", "rm", "rmdir", "sleep", "sync", "touch", "true", "unlink", "wc", "which", "whoami", "yes", ]; #[derive(Clone, Copy, Debug)] enum Feedback { Full, Changes, } impl Feedback { fn from_matches(matches: &ArgMatches) -> Option { if matches.get_flag("verbose") { Some(Feedback::Full) } else if matches.get_flag("changes") { Some(Feedback::Changes) } else { None } } }