#可执行文件 #查找 #which

which_problem

使用此Rust库诊断您的可执行文件查找问题

1 个不稳定版本

0.1.0 2023年2月2日

#1272 in 文件系统

Download history 3/week @ 2024-03-11 4/week @ 2024-03-18 38/week @ 2024-04-01 132/week @ 2024-04-22 25/week @ 2024-04-29 2/week @ 2024-05-06 9/week @ 2024-05-27 7/week @ 2024-06-03 26/week @ 2024-06-10 13/week @ 2024-06-17 7/week @ 2024-06-24

53 每月下载量
用于 2 crates

MIT 许可证

29KB
685

Which Problem (rust)

帮助您查找查找可执行文件时遇到的问题的工具。

命令行界面

使用CLI进行诊断

$ cargo install cargo-whichp
$ cargo whichp bundle

Program "bundle" found at "/Users/rschneeman/.gem/ruby/3.1.3/bin/bundle"

Warning: Executables with the same name found on the PATH:
  > [OK] "/Users/rschneeman/.gem/ruby/3.1.3/bin/bundle"
  - [OK] "/Users/rschneeman/.rubies/ruby-3.1.3/bin/bundle"
  - [OK] "/usr/local/bin/bundle"
  - [OK] "/usr/local/bin/bundle"
  - [OK] "/usr/bin/bundle"
Help: Ensure the one you want comes first and is [OK]
Explanation:
    [OK] - File found matching program name with executable permissions. Valid executable.

Info: These executables have the closest spelling to "bundle" but did not match:
      "uname", "bundler", "uuname"

Info: The following directories on PATH were searched (top to bottom):
  > [OK     ] "/Users/rschneeman/.gem/ruby/3.1.3/bin"
  - [MISSING] "/Users/rschneeman/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0/bin"
  - [OK     ] "/Users/rschneeman/.rubies/ruby-3.1.3/bin"
  - [OK     ] "/Users/rschneeman/.cargo/bin"
  - [OK     ] "/usr/local/bin"
  - [OK     ] "/usr/local/sbin"
  - [OK     ] "/usr/local/bin"
  - [OK     ] "/System/Cryptexes/App/usr/bin"
  - [OK     ] "/usr/bin"
  - [OK     ] "/bin"
  - [OK     ] "/usr/sbin"
  - [OK     ] "/sbin"
  - [OK     ] "/Users/rschneeman/.cargo/bin"
Explanation:
    [OK     ] - Path part is a valid, non-empty, directory
    [MISSING] - Path part does not exist exist on disk, no such directory

Rust 库

$ cargo add which_problem
use std::process::Command;
use which_problem::Which;

let program = "bundle";
Command::new(program)
    .arg("install")
    .output()
    .map_err(|error| {
        eprintln!("Executing command '{program}' failed. Error: {error}");

        match Which::new(program).diagnose() {
            Ok(details) => println!("Diagnostic info: {details}"),
            Err(error) => println!("Warning: Internal which_problem error: {error}"),
        }
        error
    })
    .unwrap();

依赖项

~2MB
~39K SLoC