diff options
Diffstat (limited to 'src/poem/anthology/cd.rs')
-rw-r--r-- | src/poem/anthology/cd.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/poem/anthology/cd.rs b/src/poem/anthology/cd.rs new file mode 100644 index 0000000..3b48f60 --- /dev/null +++ b/src/poem/anthology/cd.rs @@ -0,0 +1,20 @@ +use crate::poem::Verse; + +pub fn incant(verse: &Verse) -> i32 { + let path = match verse.clause() { + Some(path) => path[0].to_string(), + None => env!("HOME").to_string(), + }; + + match std::env::set_current_dir(&path) { + Ok(_) => 0, + Err(e) => { + eprintln!( + "cd: unable to change into {}: {}", + path, + e.to_string().to_lowercase() + ); + 1 + } + } +} |