diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-07-29 07:02:20 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-07-29 07:02:20 +0200 |
commit | 7d531cfbcaae2c7a141d952a0c5d9266c5f07a49 (patch) | |
tree | 99cb0c886a7dec95802c2d6de1d97914cd76ea3e | |
parent | f291892643dd00d38612347c3c007e00fab8666e (diff) |
Implement CLS.
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 0662c98..f4f5b72 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use crossterm::{cursor, execute, terminal}; use eyre::{bail, Result}; use regex::Regex; use rustyline::DefaultEditor; @@ -142,6 +143,13 @@ impl Command { exit_status.send(0)?; } + Builtin(Cls) => { + let mut stdout_handle = io::stdout(); + execute!(stdout_handle, terminal::Clear(terminal::ClearType::All))?; + execute!(stdout_handle, cursor::MoveTo(0, 0))?; + exit_status.send(0)?; + } + _ => bail!("Command::run not implemented for {:?}", self), } @@ -226,6 +234,8 @@ impl Command { _ => EchoText { message: args.to_string() }, })), + "CLS" => Ok(Builtin(Cls)), + _ => Err(eyre::eyre!("parse not implemented for {:?}", input)) } |