• Home
  • Raw
  • Download

Lines Matching +full:env +full:- +full:paths

25 use std::env;
56 pub fn which<T: AsRef<OsStr>>(binary_name: T) -> Result<path::PathBuf> { in which()
64 /// Does not resolve relative paths.
80 pub fn which_global<T: AsRef<OsStr>>(binary_name: T) -> Result<path::PathBuf> { in which_global()
84 /// Find all binaries with `binary_name` using `cwd` to resolve relative paths.
85 pub fn which_all<T: AsRef<OsStr>>(binary_name: T) -> Result<impl Iterator<Item = path::PathBuf>> { in which_all()
86 let cwd = env::current_dir().ok(); in which_all()
92 finder.find(binary_name, env::var_os("PATH"), cwd, binary_checker) in which_all()
98 ) -> Result<impl Iterator<Item = path::PathBuf>> { in which_all_global()
105 env::var_os("PATH"), in which_all_global()
117 /// * `regex` - A regular expression to match binaries with
140 /// which_re(Regex::new("^cargo-.*").unwrap()).unwrap()
144 pub fn which_re(regex: impl Borrow<Regex>) -> Result<impl Iterator<Item = path::PathBuf>> { in which_re()
145 which_re_in(regex, env::var_os("PATH")) in which_re()
148 /// Find `binary_name` in the path list `paths`, using `cwd` to resolve relative paths.
149 pub fn which_in<T, U, V>(binary_name: T, paths: Option<U>, cwd: V) -> Result<path::PathBuf> in which_in()
155 which_in_all(binary_name, paths, cwd) in which_in()
159 /// Find all binaries matching a regular expression in a list of paths.
165 /// * `regex` - A regular expression to match binaries with
166 /// * `paths` - A string containing the paths to search
177 /// let paths = Some("/usr/bin:/usr/local/bin");
178 /// let binaries: Vec<PathBuf> = which::which_re_in(re, paths).unwrap().collect();
185 paths: Option<T>, in which_re_in()
186 ) -> Result<impl Iterator<Item = path::PathBuf>> in which_re_in()
194 finder.find_re(regex, paths, binary_checker) in which_re_in()
197 …ind all binaries with `binary_name` in the path list `paths`, using `cwd` to resolve relative path…
200 paths: Option<U>, in which_in_all()
202 ) -> Result<impl Iterator<Item = path::PathBuf>> in which_in_all()
212 finder.find(binary_name, paths, Some(cwd), binary_checker) in which_in_all()
215 /// Find all binaries with `binary_name` in the path list `paths`, ignoring `cwd`.
218 paths: Option<U>, in which_in_global()
219 ) -> Result<impl Iterator<Item = path::PathBuf>> in which_in_global()
228 finder.find(binary_name, paths, Option::<&Path>::None, binary_checker) in which_in_global()
231 fn build_binary_checker() -> CompositeChecker { in build_binary_checker()
247 fn default() -> Self { in default()
265 pub fn new() -> Self { in new()
274 pub fn system_cwd(mut self, use_cwd: bool) -> Self { in system_cwd()
283 /// Sets a custom path for resolving relative paths.
288 pub fn custom_cwd(mut self, cwd: path::PathBuf) -> Self { in custom_cwd()
308 pub fn regex(mut self, regex: Regex) -> Self { in regex()
331 pub fn binary_name(mut self, name: OsString) -> Self { in binary_name()
340 /// Uses the given string instead of the `PATH` env variable.
341 pub fn custom_path_list(mut self, custom_path_list: OsString) -> Self { in custom_path_list()
346 /// Uses the `PATH` env variable. Enabled by default.
347 pub fn system_path_list(mut self) -> Self { in system_path_list()
353 pub fn first_result(self) -> Result<path::PathBuf> { in first_result()
359 pub fn all_results(self) -> Result<impl Iterator<Item = path::PathBuf>> { in all_results()
364 let paths = self.custom_path_list.or_else(|| env::var_os("PATH")); in all_results() localVariable
369 .find_re(regex, paths, binary_checker) in all_results()
376 None | Some(either::Either::Left(true)) => env::current_dir().ok(), in all_results()
384 paths, in all_results()
411 pub fn new<T: AsRef<OsStr>>(binary_name: T) -> Result<Path> { in new()
415 /// Returns the paths of all executable binaries by a name.
418 pub fn all<T: AsRef<OsStr>>(binary_name: T) -> Result<impl Iterator<Item = Path>> { in all()
422 /// Returns the path of an executable binary by name in the path list `paths` and using the
423 /// current working directory `cwd` to resolve relative paths.
426 pub fn new_in<T, U, V>(binary_name: T, paths: Option<U>, cwd: V) -> Result<Path> in new_in()
432 which_in(binary_name, paths, cwd).map(|inner| Path { inner }) in new_in()
435 /// Returns all paths of an executable binary by name in the path list `paths` and using the
436 /// current working directory `cwd` to resolve relative paths.
441 paths: Option<U>, in all_in()
443 ) -> Result<impl Iterator<Item = Path>> in all_in()
449 which_in_all(binary_name, paths, cwd).map(|inner| inner.map(|inner| Path { inner })) in all_in()
453 pub fn as_path(&self) -> &path::Path { in as_path()
458 pub fn into_path_buf(self) -> path::PathBuf { in into_path_buf()
464 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
472 fn deref(&self) -> &path::Path { in deref()
478 fn as_ref(&self) -> &path::Path { in as_ref()
484 fn as_ref(&self) -> &OsStr { in as_ref()
490 fn eq(&self, other: &path::PathBuf) -> bool { in eq()
496 fn eq(&self, other: &Path) -> bool { in eq()
523 pub fn new<T: AsRef<OsStr>>(binary_name: T) -> Result<CanonicalPath> { in new()
529 /// Returns the canonical paths of an executable binary by name.
534 ) -> Result<impl Iterator<Item = Result<CanonicalPath>>> { in all()
545 /// Returns the canonical path of an executable binary by name in the path list `paths` and
546 /// using the current working directory `cwd` to resolve relative paths.
549 pub fn new_in<T, U, V>(binary_name: T, paths: Option<U>, cwd: V) -> Result<CanonicalPath> in new_in()
555 which_in(binary_name, paths, cwd) in new_in()
560 …/// Returns all of the canonical paths of an executable binary by name in the path list `paths` and
561 /// using the current working directory `cwd` to resolve relative paths.
566 paths: Option<U>, in all_in()
568 ) -> Result<impl Iterator<Item = Result<CanonicalPath>>> in all_in()
574 which_in_all(binary_name, paths, cwd).map(|inner| { in all_in()
585 pub fn as_path(&self) -> &path::Path { in as_path()
590 pub fn into_path_buf(self) -> path::PathBuf { in into_path_buf()
596 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
604 fn deref(&self) -> &path::Path { in deref()
610 fn as_ref(&self) -> &path::Path { in as_ref()
616 fn as_ref(&self) -> &OsStr { in as_ref()
622 fn eq(&self, other: &path::PathBuf) -> bool { in eq()
628 fn eq(&self, other: &CanonicalPath) -> bool { in eq()