Skip to main content

expand_path

Function expand_path 

Source
pub fn expand_path(path: &str) -> PathBuf
Expand description

Expand a path by resolving ~ and environment variables.

This function expands:

  • ~ at the start to the user’s home directory
  • $VAR or ${VAR} to the value of the environment variable VAR

§Example

use click::utils::expand_path;

let path = expand_path("~/.config/myapp");
// Returns something like "/home/user/.config/myapp"

// With environment variables
std::env::set_var("MY_DIR", "/custom");
let path = expand_path("$MY_DIR/file.txt");
// Returns "/custom/file.txt"