Files
packie/cli/src/info.rs
T
2026-06-26 18:12:50 +08:00

31 lines
948 B
Rust

use crate::common::format_size;
use anyhow::anyhow;
use clap::Parser;
use packie::{PackieBuilder, package::PkgSpec};
use rust_i18n::t;
#[derive(Debug, Parser)]
pub struct Cli {
pkgspec: PkgSpec,
}
pub fn main(cli: Cli) -> anyhow::Result<()> {
let mut packie = PackieBuilder::new().readonly(true).build()?;
let mut found = packie.search_installation(&cli.pkgspec)?;
if found.len() == 0 {
return Err(anyhow!("{}", t!("info.no_package_found")));
}
if found.len() != 1 {
return Err(anyhow!("{}", t!("info.pkgspec_not_unique")));
}
let found = found.remove(0);
println!("Package name: {}", found.pkg_manifest.name);
println!("Package version: {}", found.pkg_manifest.version);
println!("Package architecture: {}", found.pkg_manifest.arch);
println!("Install package spec: {}", found.install_pkgspec);
println!("Installed size: {}", format_size(found.installed_size));
Ok(())
}