implement --version for checking program version

This commit is contained in:
raf 2024-10-22 15:25:01 +03:00
parent 9ed9e8d930
commit 8f2536608f
Signed by: NotAShelf
GPG key ID: AF26552424E53993

View file

@ -17,6 +17,10 @@ use color_eyre::Report;
fn main() -> Result<(), Report> {
color_eyre::install()?;
let args: Vec<String> = std::env::args().collect();
if args.len() > 1 && args[1] == "--version" {
println!("Microfetch {}", env!("CARGO_PKG_VERSION"));
} else {
let utsname = nix::sys::utsname::uname()?;
let fields = Fields {
user_info: get_username_and_hostname(&utsname),
@ -29,8 +33,8 @@ fn main() -> Result<(), Report> {
storage: get_root_disk_usage()?,
colors: print_dots(),
};
print_system_info(&fields);
}
Ok(())
}