2024-05-30 10:13:37 -04:00
|
|
|
use std::path::Path;
|
2024-05-30 09:03:46 -04:00
|
|
|
|
|
|
|
use pico_args::Arguments;
|
|
|
|
|
|
|
|
const DRIVE: &str = "/mnt/c/";
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
let mut args = Arguments::from_env();
|
|
|
|
|
|
|
|
loop {
|
|
|
|
let next = args.subcommand().unwrap();
|
2024-05-30 10:13:37 -04:00
|
|
|
if let Some(arg) = next {
|
|
|
|
let mut output: String;
|
|
|
|
// resolve symlinks, etc.
|
|
|
|
let path = Path::new(&arg).canonicalize();
|
|
|
|
if let Ok(target) = path {
|
|
|
|
output = target.to_string_lossy().to_string();
|
|
|
|
} else {
|
|
|
|
output = arg;
|
2024-05-30 09:03:46 -04:00
|
|
|
}
|
2024-05-30 10:13:37 -04:00
|
|
|
|
|
|
|
if output.starts_with(DRIVE) {
|
|
|
|
output = output.replace(DRIVE, "C:\\");
|
|
|
|
}
|
|
|
|
|
|
|
|
output = output.replace("/", "\\");
|
|
|
|
|
|
|
|
println!("{output}");
|
2024-05-30 09:03:46 -04:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|