add --print-package

requested in https://github.com/nix-community/comma/issues/38
This commit is contained in:
Artturin 2022-11-20 18:49:19 +02:00
parent 78456e7c5f
commit 34ba5a05bc

View File

@ -114,6 +114,14 @@ fn main() -> ExitCode {
}
.contains("nixpkgs");
if args.print_package {
println!(
"Package that contains executable /bin/{}: {}",
command,
&choice.rsplit('.').last().unwrap()
);
};
if args.install {
Command::new("nix-env")
.args(["-f", "<nixpkgs>", "-iA", choice.rsplit('.').last().unwrap()])
@ -140,6 +148,10 @@ struct Opt {
#[clap(short, long)]
update: bool,
/// Print the package containing the executable
#[clap(long = "print-package")]
print_package: bool,
/// Command to run
#[clap(required_unless_present = "update", name = "cmd")]
cmd: Vec<String>,