1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::fs;
use std::io;
pub fn help() {
println!(
"reelpath {}
https://github.com/nickgerace/reelpath
Find the absolute path of a given file or directory.
USAGE:
reelpath [path]",
option_env!("CARGO_PKG_VERSION").unwrap_or("v?")
);
}
pub fn run(s: &str) -> io::Result<()> {
match s {
"-h" | "-help" | "--help" => help(),
_ => match fs::canonicalize(s) {
Ok(o) => println!("{}", o.display()),
Err(e) => return Err(e),
},
}
Ok(())
}