modcli/
shell_extensions.rs1use crate::config::CliConfig;
2use crate::output::{print, build};
3use std::io::{self, Write};
4
5pub fn dispatch_shell_command(input: &str, config: &CliConfig) -> bool {
6 match input.trim() {
7 "clear" => {
8 clear_screen();
9 true
10 }
11 "project" => {
12 let project = config.modcli.name.as_deref().unwrap_or("Unknown");
13 let msg = build()
14 .part("Current Project: ").bold()
15 .part(project).underline().get();
16 print::line(&msg);
17 true
18 }
19 "?" | "shell help" => {
20 print::info("Shell Commands:");
21 print::line(" clear - Clear the terminal");
22 print::line(" project - Show active project name");
23 print::line(" exit/quit - Leave shell");
24 true
25 }
26 _ => false,
27 }
28}
29
30fn clear_screen() {
31 print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
32 io::stdout().flush().unwrap();
33}