From e2455594f4d41c04fe0fbd8f2503facf7c75669d Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sat, 4 Mar 2023 23:19:51 -0600 Subject: [PATCH] looks like I'm cookin with gas now --- src/main.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index fbdce52..d3e0749 100644 --- a/src/main.rs +++ b/src/main.rs @@ -154,6 +154,14 @@ fn eval(line: String) -> Result<()> { println!("{}", pb.as_path().as_os_str().to_str().unwrap()); return Ok(()); } + "cd" => { + let cwd = std::env::current_dir()?; + if parts.len() > 1 { + let target = cwd.join(parts[1]); + std::env::set_current_dir(target)?; + return Ok(()); + } + } "printenv" => { if parts.len() > 1 { let name = parts[1]; @@ -188,6 +196,10 @@ fn eval(line: String) -> Result<()> { } _ => { let mut proc = std::process::Command::new(cmd); + if parts.len() > 1 { + let args = parts[1..].to_vec(); + proc.args(args); + } match proc.spawn() { Ok(mut child) => { if let Err(e) = child.wait() { @@ -233,7 +245,9 @@ fn main() -> Result<()> { if event.code == key::ENTER { newline(stdout)?; - eval(line.pop())?; + if let Err(e) = eval(line.pop()) { + println!("error: {}", e); + } prompt.print()?; continue; }