Remove Default
constraint on Cmd
trait and begin removing
derive(Default) from applets
This commit is contained in:
parent
edbabc11c1
commit
d248f7d17b
@ -9,7 +9,7 @@ use std::{
|
||||
};
|
||||
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Base32;
|
||||
|
||||
impl Cmd for Base32 {
|
||||
|
@ -8,7 +8,7 @@ use std::{
|
||||
};
|
||||
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Base64;
|
||||
|
||||
impl Cmd for Base64 {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::Cmd;
|
||||
use clap::{Arg, ArgMatches, Command};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Basename;
|
||||
|
||||
impl Cmd for Basename {
|
||||
|
@ -10,7 +10,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Bootstrap;
|
||||
|
||||
impl Bootstrap {
|
||||
|
@ -11,7 +11,7 @@ use std::{
|
||||
};
|
||||
use walkdir::{DirEntry, WalkDir};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Chmod;
|
||||
|
||||
impl Cmd for Chmod {
|
||||
|
@ -13,7 +13,7 @@ use walkdir::{DirEntry, WalkDir};
|
||||
mod chgrp;
|
||||
pub use chgrp::Chgrp;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Chown;
|
||||
|
||||
impl Cmd for Chown {
|
||||
|
@ -6,7 +6,7 @@ use std::{
|
||||
process,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Chroot;
|
||||
|
||||
impl Cmd for Chroot {
|
||||
|
@ -3,7 +3,7 @@ use clap::Command;
|
||||
use shitbox::Cmd;
|
||||
use std::{error::Error, process};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Corebox;
|
||||
|
||||
impl Cmd for Corebox {
|
||||
|
@ -8,7 +8,7 @@ use std::{
|
||||
usize, vec,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Cut;
|
||||
|
||||
impl Cmd for Cut {
|
||||
|
@ -4,7 +4,7 @@ use shitbox::Cmd;
|
||||
use size_display::Size;
|
||||
use std::{error::Error, fmt, io, path::PathBuf};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Df;
|
||||
|
||||
impl Cmd for Df {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Dirname;
|
||||
|
||||
impl Cmd for Dirname {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{Arg, Command};
|
||||
use std::{env, error::Error};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Echo;
|
||||
|
||||
impl Cmd for Echo {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command, ValueHint};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Expand;
|
||||
|
||||
impl Cmd for Expand {
|
||||
|
@ -5,7 +5,7 @@ use std::{
|
||||
io::{self, BufRead},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Factor;
|
||||
|
||||
impl Cmd for Factor {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::Command;
|
||||
use std::{error::Error, process};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct False;
|
||||
|
||||
impl Cmd for False {
|
||||
|
@ -6,7 +6,7 @@ use std::{
|
||||
};
|
||||
use textwrap::{fill, wrap_algorithms::WrapAlgorithm};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Fold;
|
||||
|
||||
impl Cmd for Fold {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::Cmd;
|
||||
use clap::{Arg, Command};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Groups;
|
||||
|
||||
impl Cmd for Groups {
|
||||
|
@ -9,7 +9,7 @@ use std::{
|
||||
};
|
||||
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Head;
|
||||
|
||||
impl Cmd for Head {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::Cmd;
|
||||
use clap::Command;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Hostid;
|
||||
|
||||
impl Cmd for Hostid {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use std::{error::Error, io};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Hostname;
|
||||
|
||||
impl Cmd for Hostname {
|
||||
|
@ -3,7 +3,7 @@ use clap::{Arg, Command};
|
||||
use shitbox::args;
|
||||
use std::{fs, io};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Link;
|
||||
|
||||
impl Cmd for Link {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::{error::Error, fs, io, os, path::PathBuf};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Ln;
|
||||
|
||||
impl Cmd for Ln {
|
||||
|
@ -3,7 +3,7 @@ use std::ffi::CStr;
|
||||
use super::Cmd;
|
||||
use clap::Command;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Logname;
|
||||
|
||||
impl Cmd for Logname {
|
||||
|
@ -4,7 +4,7 @@ use mode::Parser;
|
||||
use shitbox::args;
|
||||
use std::error::Error;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct MkFifo;
|
||||
|
||||
impl Cmd for MkFifo {
|
||||
|
@ -4,7 +4,7 @@ use mode::{get_umask, Parser};
|
||||
use shitbox::args;
|
||||
use std::{convert::Infallible, error::Error, io, str::FromStr};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct MkNod;
|
||||
|
||||
impl Cmd for MkNod {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command, ValueHint};
|
||||
use std::{ffi::CString, fs, io, path::PathBuf};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct MkTemp;
|
||||
|
||||
impl Cmd for MkTemp {
|
||||
|
@ -57,55 +57,54 @@ mod yes;
|
||||
|
||||
/// 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 {
|
||||
"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())),
|
||||
"base64" => Some(Box::new(base64::Base64)),
|
||||
"base32" => Some(Box::new(base32::Base32)),
|
||||
"basename" => Some(Box::new(basename::Basename)),
|
||||
"bootstrap" => Some(Box::new(bootstrap::Bootstrap)),
|
||||
"chmod" => Some(Box::new(chmod::Chmod)),
|
||||
"chgrp" => Some(Box::new(chown::Chgrp)),
|
||||
"chown" => Some(Box::new(chown::Chown)),
|
||||
"chroot" => Some(Box::new(chroot::Chroot)),
|
||||
"corebox" => Some(Box::new(corebox::Corebox)),
|
||||
"cut" => Some(Box::new(cut::Cut)),
|
||||
"df" => Some(Box::new(df::Df)),
|
||||
"dirname" => Some(Box::new(dirname::Dirname)),
|
||||
"echo" => Some(Box::new(echo::Echo)),
|
||||
"factor" => Some(Box::new(factor::Factor)),
|
||||
"false" => Some(Box::new(r#false::False)),
|
||||
"fold" => Some(Box::new(fold::Fold)),
|
||||
"groups" => Some(Box::new(groups::Groups)),
|
||||
"head" => Some(Box::new(head::Head)),
|
||||
"hostid" => Some(Box::new(hostid::Hostid)),
|
||||
"hostname" => Some(Box::new(hostname::Hostname)),
|
||||
"link" => Some(Box::new(link::Link)),
|
||||
"ln" => Some(Box::new(ln::Ln)),
|
||||
"logname" => Some(Box::new(logname::Logname)),
|
||||
"mkfifo" => Some(Box::new(mkfifo::MkFifo)),
|
||||
"mknod" => Some(Box::new(mknod::MkNod)),
|
||||
"mktemp" => Some(Box::new(mktemp::MkTemp)),
|
||||
"nologin" => Some(Box::new(nologin::Nologin)),
|
||||
"nproc" => Some(Box::new(nproc::Nproc)),
|
||||
"printenv" => Some(Box::new(printenv::Printenv)),
|
||||
"pwd" => Some(Box::new(pwd::Pwd)),
|
||||
"readlink" => Some(Box::new(readlink::Readlink)),
|
||||
"realpath" => Some(Box::new(realpath::Realpath)),
|
||||
"rev" => Some(Box::new(rev::Rev)),
|
||||
"rm" => Some(Box::new(rm::Rm)),
|
||||
"rmdir" => Some(Box::new(rmdir::Rmdir)),
|
||||
"sleep" => Some(Box::new(sleep::Sleep)),
|
||||
"sync" => Some(Box::new(sync::Sync)),
|
||||
"touch" => Some(Box::new(touch::Touch)),
|
||||
"true" => Some(Box::new(r#true::True)),
|
||||
"truncate" => Some(Box::new(truncate::Truncate)),
|
||||
"unlink" => Some(Box::new(unlink::Unlink::default())),
|
||||
"wc" => Some(Box::new(wc::Wc::default())),
|
||||
"which" => Some(Box::new(which::Which::default())),
|
||||
"who" => Some(Box::new(who::Who::default())),
|
||||
"whoami" => Some(Box::new(whoami::Whoami::default())),
|
||||
"yes" => Some(Box::new(yes::Yes::default())),
|
||||
"unlink" => Some(Box::new(unlink::Unlink)),
|
||||
"wc" => Some(Box::new(wc::Wc)),
|
||||
"which" => Some(Box::new(which::Which)),
|
||||
"who" => Some(Box::new(who::Who)),
|
||||
"whoami" => Some(Box::new(whoami::Whoami)),
|
||||
"yes" => Some(Box::new(yes::Yes)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::Command;
|
||||
use std::process;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Nologin;
|
||||
|
||||
impl Cmd for Nologin {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Nproc;
|
||||
|
||||
impl Cmd for Nproc {
|
||||
|
@ -3,7 +3,7 @@ use std::env;
|
||||
use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Printenv;
|
||||
|
||||
impl Cmd for Printenv {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Pwd;
|
||||
|
||||
impl Cmd for Pwd {
|
||||
|
@ -2,7 +2,7 @@ use clap::{Arg, ArgAction, ArgMatches, Command, ValueHint};
|
||||
use shitbox::Cmd;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Readlink;
|
||||
|
||||
impl Cmd for Readlink {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command, ValueHint};
|
||||
use std::{env, fs, process};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Realpath;
|
||||
|
||||
impl Cmd for Realpath {
|
||||
|
@ -7,7 +7,7 @@ use std::{
|
||||
};
|
||||
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Rev;
|
||||
|
||||
impl Cmd for Rev {
|
||||
|
@ -10,7 +10,7 @@ use std::{
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Rm;
|
||||
|
||||
impl Cmd for Rm {
|
||||
|
@ -3,7 +3,7 @@ use clap::{Arg, ArgAction, Command, ValueHint};
|
||||
use shitbox::args;
|
||||
use std::{error::Error, fs, path::Path};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Rmdir;
|
||||
|
||||
impl Cmd for Rmdir {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{value_parser, Arg, ArgAction, ArgMatches, Command};
|
||||
use std::{env, error::Error, thread, time::Duration};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Sleep;
|
||||
|
||||
impl Cmd for Sleep {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::{error::Error, fs::OpenOptions};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Sync;
|
||||
|
||||
impl Cmd for Sync {
|
||||
|
@ -4,7 +4,7 @@ use filetime::*;
|
||||
use shitbox::Cmd;
|
||||
use std::{error::Error, fs::File, io, path::PathBuf};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Touch;
|
||||
|
||||
impl Cmd for Touch {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::Command;
|
||||
use std::{error::Error, process};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct True;
|
||||
|
||||
impl Cmd for True {
|
||||
|
@ -4,7 +4,7 @@ use {
|
||||
std::{error::Error, fmt, fs::{self, File}, num::ParseIntError, path::PathBuf},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Truncate;
|
||||
|
||||
impl Cmd for Truncate {
|
||||
|
@ -2,7 +2,7 @@ use super::Cmd;
|
||||
use clap::{Arg, Command};
|
||||
use shitbox::args;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Unlink;
|
||||
|
||||
impl Cmd for Unlink {
|
||||
|
@ -11,7 +11,7 @@ use std::{
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Wc;
|
||||
|
||||
impl Cmd for Wc {
|
||||
|
@ -4,7 +4,7 @@ use clap::{Arg, Command};
|
||||
use mode::Bit;
|
||||
use std::{env, fs::File, os::unix::prelude::MetadataExt, path::PathBuf, process};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Which;
|
||||
|
||||
impl Cmd for Which {
|
||||
|
@ -2,7 +2,7 @@ use clap::{Arg, ArgAction, Command};
|
||||
use shitbox::Cmd;
|
||||
use utmp_rs::UtmpEntry;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Who;
|
||||
|
||||
impl Cmd for Who {
|
||||
|
@ -5,7 +5,7 @@ use {
|
||||
std::ffi::CStr,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Whoami;
|
||||
|
||||
impl Cmd for Whoami {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::Cmd;
|
||||
use clap::{Arg, Command};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Yes;
|
||||
|
||||
impl Cmd for Yes {
|
||||
|
@ -12,18 +12,17 @@ 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())),
|
||||
"bootstrap" => Some(Box::new(bootstrap::Bootstrap::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())),
|
||||
"b2sum" => Some(Box::new(b2sum::B2sum)),
|
||||
"bootstrap" => Some(Box::new(bootstrap::Bootstrap)),
|
||||
"hashbox" => Some(Box::new(hashbox::Hashbox)),
|
||||
"md5sum" => Some(Box::new(md5sum::Md5sum)),
|
||||
"sha1sum" => Some(Box::new(sha1sum::Sha1sum)),
|
||||
"sha224sum" => Some(Box::new(sha224sum::Sha224sum)),
|
||||
"sha256sum" => Some(Box::new(sha256sum::Sha256sum)),
|
||||
"sha384sum" => Some(Box::new(sha384sum::Sha384sum)),
|
||||
"sha512sum" => Some(Box::new(sha512sum::Sha512sum)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use clap::ArgMatches;
|
||||
use std::{error::Error, fmt};
|
||||
use std::error::Error;
|
||||
|
||||
/// Defines a command or applet, it's cli interface, and it's installation directory
|
||||
/// relative to the binary
|
||||
pub trait Cmd: fmt::Debug + Sync {
|
||||
pub trait Cmd: Sync {
|
||||
/// Defines the cli of the applet
|
||||
fn cli(&self) -> clap::Command;
|
||||
/// Runs the applet
|
||||
|
@ -10,7 +10,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Bootstrap;
|
||||
|
||||
impl Bootstrap {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::Cmd;
|
||||
use clap::Command;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Clear;
|
||||
|
||||
impl Cmd for Clear {
|
||||
|
@ -13,16 +13,15 @@ mod utilbox;
|
||||
|
||||
/// 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 {
|
||||
"bootstrap" => Some(Box::new(bootstrap::Bootstrap::default())),
|
||||
"clear" => Some(Box::new(clear::Clear::default())),
|
||||
"mountpoint" => Some(Box::new(mountpoint::Mountpoint::default())),
|
||||
"swaplabel" => Some(Box::new(swaplabel::Swaplabel::default())),
|
||||
"swapoff" => Some(Box::new(swapoff::Swapoff::default())),
|
||||
"umount" => Some(Box::new(umount::Umount::default())),
|
||||
"utilbox" => Some(Box::new(utilbox::Utilbox::default())),
|
||||
"bootstrap" => Some(Box::new(bootstrap::Bootstrap)),
|
||||
"clear" => Some(Box::new(clear::Clear)),
|
||||
"mountpoint" => Some(Box::new(mountpoint::Mountpoint)),
|
||||
"swaplabel" => Some(Box::new(swaplabel::Swaplabel)),
|
||||
"swapoff" => Some(Box::new(swapoff::Swapoff)),
|
||||
"umount" => Some(Box::new(umount::Umount)),
|
||||
"utilbox" => Some(Box::new(utilbox::Utilbox)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use clap::{ArgMatches, Command};
|
||||
use shitbox::Cmd;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Mount;
|
||||
|
||||
impl Cmd for Mount {
|
||||
|
@ -9,7 +9,7 @@ use std::{
|
||||
process,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Mountpoint;
|
||||
|
||||
impl Cmd for Mountpoint {
|
||||
|
@ -19,7 +19,7 @@ lazy_static! {
|
||||
unsafe { libc::sysconf(libc::_SC_PAGESIZE) as u64 - SWAP_MAGIC_LENGTH };
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Swaplabel;
|
||||
|
||||
impl Cmd for Swaplabel {
|
||||
|
@ -6,7 +6,7 @@ use std::{
|
||||
io::{self, BufRead, BufReader},
|
||||
};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Swapoff;
|
||||
|
||||
impl Cmd for Swapoff {
|
||||
|
@ -3,7 +3,7 @@ use mount::MntEntries;
|
||||
use shitbox::{args, Cmd};
|
||||
use std::io;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Umount;
|
||||
|
||||
impl Cmd for Umount {
|
||||
|
@ -3,7 +3,7 @@ use clap::Command;
|
||||
use shitbox::Cmd;
|
||||
use std::{error::Error, process};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct Utilbox;
|
||||
|
||||
impl Cmd for Utilbox {
|
||||
|
Loading…
Reference in New Issue
Block a user