Skip to main content

resolve_vault_path

Function resolve_vault_path 

Source
pub fn resolve_vault_path(arg: &str) -> String
Expand description

Resolve a vault path argument, walking up parent directories to discover the vault.

Mirrors how git finds .git and cargo finds Cargo.toml: if the user passed a bare filename (no path separator, not absolute) and it does not exist in the current directory, walk up from CWD looking for a file of that name. Stops at:

  • a directory containing .git (the git root — don’t escape the repo)
  • $HOME (don’t traverse into parents of the user’s home)
  • the filesystem root

If a match is found, returns the absolute path. Otherwise returns the input unchanged, so downstream error messages still reference what the user asked for.

Explicit paths (absolute, or containing / or \) are returned unchanged — the user told us exactly where to look, so don’t second-guess them.