modcli/
shell_extensions.rs1use crate::config::CliConfig;
2use crate::output::{build, print};
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: ")
15 .bold()
16 .part(project)
17 .underline()
18 .get();
19 print::line(&msg);
20 true
21 }
22 "?" | "shell help" => {
23 print::info("Shell Commands:");
24 print::line(" clear - Clear the terminal");
25 print::line(" project - Show active project name");
26 print::line(" exit/quit - Leave shell");
27 true
28 }
29 _ => false,
30 }
31}
32
33fn clear_screen() {
34 print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
35 io::stdout().flush().unwrap();
36}