diff options
author | Rory Dudley | 2024-02-20 23:18:42 -0700 |
---|---|---|
committer | Rory Dudley | 2024-02-20 23:18:42 -0700 |
commit | a14fdf8faa85628baf06399961eb1f9ab4c5f3eb (patch) | |
tree | 61bd14d2131f02b77d6ec0eb0314d7a91fade191 /src/main.rs | |
parent | 309a101a0e09ffe2bcd4f0032744f8532a5988d1 (diff) | |
download | dwarvish-a14fdf8faa85628baf06399961eb1f9ab4c5f3eb.tar.gz |
Add back the 'cd' command
Add back change directory functionality into the new parser.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 17 |
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) { |