summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRory Dudley2024-02-20 23:18:42 -0700
committerRory Dudley2024-02-20 23:18:42 -0700
commita14fdf8faa85628baf06399961eb1f9ab4c5f3eb (patch)
tree61bd14d2131f02b77d6ec0eb0314d7a91fade191
parent309a101a0e09ffe2bcd4f0032744f8532a5988d1 (diff)
downloaddwarvish-a14fdf8faa85628baf06399961eb1f9ab4c5f3eb.tar.gz
Add back the 'cd' command
Add back change directory functionality into the new parser.
-rw-r--r--src/main.rs17
1 files changed, 17 insertions, 0 deletions
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) {