#[non_exhaustive]pub struct ProjectInput<'a> { /* private fields */ }Expand description
Process-like path inputs used to resolve a project root.
Build one with ProjectInput::new and the chainable setters. Project root
resolution is best-effort and uses a stable fallback order:
cwd- parent of
exe, for executables that are not known runtimes or tools - parents of absolute paths in
cmd
Relative command-line arguments are ignored because they cannot be resolved safely without knowing the process working directory at the time the command started.
The home-directory ceiling is not part of the input. It is configured on
StackDetector or passed to
resolve_project_root directly.
§Examples
use std::path::Path;
use what_stack::ProjectInput;
let input = ProjectInput::new()
.cwd(Path::new("/workspace/api/src"))
.exe(None);Implementations§
Source§impl<'a> ProjectInput<'a>
impl<'a> ProjectInput<'a>
Sourcepub fn cwd(self, cwd: impl Into<Option<&'a Path>>) -> Self
pub fn cwd(self, cwd: impl Into<Option<&'a Path>>) -> Self
Set the process working directory.
This is the most trustworthy project-root hint and is checked first.
Accepts a &Path or an Option<&Path>.
Sourcepub fn exe(self, exe: impl Into<Option<&'a Path>>) -> Self
pub fn exe(self, exe: impl Into<Option<&'a Path>>) -> Self
Set the process executable path.
The parent directory is searched when the working directory is missing
or does not resolve to a project, unless the executable is a known
runtime or tool such as node or python. A root found this way is
ignored when it lies in a dot directory directly under the home
ceiling, such as ~/.nvm or ~/.cargo. Accepts a &Path or an
Option<&Path>.