diff options
author | Rory Dudley | 2024-02-16 22:54:48 -0700 |
---|---|---|
committer | Rory Dudley | 2024-02-16 22:54:48 -0700 |
commit | 22645fe49fcf488b46fbbcfae7d189c5c9c8c350 (patch) | |
tree | 820e062f89910295b7fbb74346d9bb9e1935a95e /src | |
parent | c101a8c2abf0c25fc75e4101a83ae56bc2a9b789 (diff) | |
download | dwarvish-22645fe49fcf488b46fbbcfae7d189c5c9c8c350.tar.gz |
Change directories
Added logic to change directories with 'cd'.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index f78e54d..1ff551c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,6 +57,25 @@ fn eval(paths: &[&str], prompt: &str) { } } + // Check if user wants to change directories + if cmd == "cd" { + let path = match args.first() { + Some(str) => str, + None => { + println!("cd: Must specify a path"); + continue; + } + }; + match std::env::set_current_dir(path) { + Ok(_) => {} + Err(_) => { + println!("cd: Unable to change into {}", path); + continue; + } + } + continue; + } + // Check if the command exists let cmd = match bins.iter().find(|b| b.split("/").last().unwrap() == cmd) { Some(cmd) => cmd, |