feat: debug command only in debug mode

This commit is contained in:
Strix 2023-10-14 22:39:47 +02:00
parent 63187649d8
commit 4e0bb7dfa3
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774

View file

@ -39,7 +39,12 @@ pub enum Command {
},
/// Update packages on the system
Update,
#[command(hide = true)]
/// Get info about pkgr
Info {
#[arg(short, long, default_value_t = false)]
detailed: bool
},
#[cfg(debug_assertions)]
Debug,
#[command(hide = true)]
None,
@ -60,7 +65,7 @@ impl Command {
.unwrap();
info!("Parsing package...");
trace!("Fetching package: {}", package_identifier);
trace!("Fetching package: {:?}", package_identifier);
let mut pkg = Package::try_fetch(package_identifier.clone()).unwrap();
debug!("manifest size: {}kb", pkg.pkgfile.manifest.len() / 1024);
debug!("files size: {}kb", pkg.pkgfile.data.len() / 1024);
@ -107,6 +112,23 @@ impl Command {
Command::Update => {
error!("Update is not yet implemented.");
}
Command::Info {
detailed
} => {
info!("Welcome to pkgr!\n\
{}\n\
To get help please run \"{} -h\"", env!("CARGO_PKG_DESCRIPTION"), std::env::args().nth(0).unwrap());
if *detailed {
info!("");
info!("version: {}", env!("CARGO_PKG_VERSION"));
info!("authors: {}", env!("CARGO_PKG_AUTHORS"));
info!("");
info!("If you can't seem to figure something out, use debug!");
trace!("Trace should really only be used by PKGR devs.");
}
}
#[cfg(debug_assertions)]
Command::Debug => {
trace!("Trace message.\nWith newline.");
debug!("Debug message.\nWith newline.");
@ -124,10 +146,6 @@ impl Command {
.unwrap();
}
info!("");
info!("PKGR VERSION: {}", env!("CARGO_PKG_VERSION"));
info!("PKGR AUTHORS: {}", env!("CARGO_PKG_AUTHORS"));
info!("PKGR DESCRIPTION: {}", env!("CARGO_PKG_DESCRIPTION"));
info!("");
info!(
"PKGR_LOG_LEVEL: {}",