1pub mod bash;
2pub mod edit;
3pub mod find;
4pub mod grep;
5pub mod ls;
6pub mod read;
7pub mod write;
8
9pub(crate) fn resolve_path(cwd: &str, path: &str) -> String {
12 if path.starts_with('/') {
13 path.to_string()
14 } else {
15 format!("{}/{}", cwd.trim_end_matches('/'), path)
16 }
17}
18
19#[cfg(test)]
20mod tests {
21 use super::*;
22
23 #[test]
24 fn absolute_path_unchanged() {
25 assert_eq!(resolve_path("/project", "/abs/file.txt"), "/abs/file.txt");
26 }
27
28 #[test]
29 fn relative_path_joined() {
30 assert_eq!(resolve_path("/project", "src/main.rs"), "/project/src/main.rs");
31 }
32
33 #[test]
34 fn cwd_trailing_slash_stripped() {
35 assert_eq!(resolve_path("/project/", "file.txt"), "/project/file.txt");
36 }
37}