shitbox/utilbox/commands/clear/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

25 lines
565 B
Rust

use super::Cmd;
use clap::Command;
#[derive(Debug)]
pub struct Clear;
impl Cmd for Clear {
fn cli(&self) -> Command {
Command::new("clear")
.about("clear the terminal's screen")
.author("Nathan Fisher")
.version(env!("CARGO_PKG_VERSION"))
}
fn run(&self, _matches: &clap::ArgMatches) -> Result<(), Box<dyn std::error::Error>> {
print!("\x1b[2J\x1b[H");
print!("\x1b[3J\x1b[H");
Ok(())
}
fn path(&self) -> Option<shitbox::Path> {
Some(shitbox::Path::UsrBin)
}
}