-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::env; | ||
|
||
pub fn get_current_dir() -> anyhow::Result<String> { | ||
let current_dir = env::current_dir().unwrap(); | ||
|
||
let current_dir = current_dir | ||
.file_name() | ||
.and_then(|name| name.to_str()) | ||
.ok_or_else(|| anyhow::anyhow!("Failed to get directory name"))?; | ||
|
||
Ok(current_dir.to_string()) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_get_current_dir() { | ||
let current_dir = get_current_dir(); | ||
|
||
assert_eq!(current_dir.unwrap(), "cli") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ mod cli; | |
mod commands; | ||
mod constants; | ||
mod crates_io; | ||
mod dir; | ||
mod download; | ||
mod editor; | ||
|
||
|