thot_cli/
common.rs

1use crate::result::Result;
2use std::env;
3use std::path::PathBuf;
4use thot_local::common::canonicalize_path;
5
6/// Returns the absolute version of the path, relative to the current directory, if path is relative.
7pub fn abs_path(path: PathBuf) -> Result<PathBuf> {
8    let mut path = path;
9    if path.is_relative() {
10        let cwd = env::current_dir()?;
11        path = cwd.join(path);
12    };
13
14    path = canonicalize_path(path)?;
15    Ok(path)
16}