Nathan Fisher
fb389fd309
- one match statement to return a `Box<dyn Cmd>` - one array containing all command names Only two places to register new commands (besides their module), both in crate::cmd::mod.rs. Also removes `once_cell` crate dependency. Replace `base64` crate dependency with `data_encoding::BASE64` so that both base32 and base64 commands use the same crate.
41 lines
814 B
Rust
41 lines
814 B
Rust
use super::Cmd;
|
|
use crate::Path;
|
|
use clap::Command;
|
|
use std::{error::Error, process};
|
|
|
|
#[derive(Debug)]
|
|
pub struct True {
|
|
name: &'static str,
|
|
path: Option<Path>,
|
|
}
|
|
|
|
impl Default for True {
|
|
fn default() -> Self {
|
|
Self {
|
|
name: "true",
|
|
path: Some(crate::Path::Bin),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Cmd for True {
|
|
fn name(&self) -> &str {
|
|
self.name
|
|
}
|
|
|
|
fn cli(&self) -> clap::Command {
|
|
Command::new(self.name)
|
|
.about("Does nothing successfully")
|
|
.long_about("Exit with a status code indicating success")
|
|
.author("Nathan Fisher")
|
|
}
|
|
|
|
fn run(&self, _matches: Option<&clap::ArgMatches>) -> Result<(), Box<dyn Error>> {
|
|
process::exit(0);
|
|
}
|
|
|
|
fn path(&self) -> Option<Path> {
|
|
self.path
|
|
}
|
|
}
|