shitbox/corebox/commands/yes/mod.rs
Nathan Fisher d248f7d17b Remove Default constraint on Cmd trait and begin removing
derive(Default) from applets
2023-04-17 23:27:57 -04:00

26 lines
636 B
Rust

use super::Cmd;
use clap::{Arg, Command};
#[derive(Debug)]
pub struct Yes;
impl Cmd for Yes {
fn cli(&self) -> clap::Command {
Command::new("yes")
.about("output a string repeatedly until killed")
.author("Nathan Fisher")
.arg(Arg::new("msg").num_args(1).default_value("y"))
}
fn run(&self, matches: &clap::ArgMatches) -> Result<(), Box<dyn std::error::Error>> {
let msg = matches.get_one::<String>("msg").unwrap();
loop {
println!("{msg}");
}
}
fn path(&self) -> Option<shitbox::Path> {
Some(shitbox::Path::UsrBin)
}
}