From a14fdf8faa85628baf06399961eb1f9ab4c5f3eb Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Tue, 20 Feb 2024 23:18:42 -0700 Subject: Add back the 'cd' command Add back change directory functionality into the new parser. --- src/main.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index d167d04..3c016e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -116,6 +116,23 @@ impl Poem { exit(0); } + if verse.verb() == "cd" { + let path: String; + if verse.clause().is_empty() { + path = env!("HOME").to_string(); + } else { + path = verse.clause().first().unwrap().to_owned(); + } + + match std::env::set_current_dir(&path) { + Ok(_) => continue, + Err(_) => { + println!("cd: unable to change into {}", path); + continue; + } + } + } + if !verse.spellcheck(bins) { *bins = prefresh(paths); if !verse.spellcheck(bins) { -- cgit v1.2.3