2023-01-07 18:30:22 -05:00
|
|
|
use super::Cmd;
|
|
|
|
use clap::{Arg, Command};
|
|
|
|
use std::io;
|
|
|
|
|
2023-01-13 01:08:32 -05:00
|
|
|
#[derive(Debug, Default)]
|
|
|
|
pub struct Yes;
|
2023-01-07 18:30:22 -05:00
|
|
|
|
|
|
|
impl Cmd for Yes {
|
|
|
|
fn cli(&self) -> clap::Command {
|
2023-01-13 01:08:32 -05:00
|
|
|
Command::new("yes")
|
2023-01-07 18:30:22 -05:00
|
|
|
.about("output a string repeatedly until killed")
|
|
|
|
.author("Nathan Fisher")
|
|
|
|
.arg(Arg::new("msg").num_args(1).default_value("y"))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run(&self, matches: Option<&clap::ArgMatches>) -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
let Some(matches) = matches else {
|
|
|
|
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "no input")));
|
|
|
|
};
|
|
|
|
let msg = matches.get_one::<String>("msg").unwrap();
|
|
|
|
loop {
|
|
|
|
println!("{msg}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn path(&self) -> Option<crate::Path> {
|
2023-01-13 01:08:32 -05:00
|
|
|
Some(crate::Path::UsrBin)
|
2023-01-07 18:30:22 -05:00
|
|
|
}
|
|
|
|
}
|