feat: debug command only in debug mode
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Didier Slof 2023-08-07 04:27:14 +02:00
parent d898370d82
commit f8b31c4c80
Signed by: didier
GPG key ID: 01E71F18AA4398E5

View file

@ -39,7 +39,12 @@ pub enum Command {
}, },
/// Update packages on the system /// Update packages on the system
Update, Update,
#[command(hide = true)] /// Get info about pkgr
Info {
#[arg(short, long, default_value_t = false)]
detailed: bool
},
#[cfg(debug_assertions)]
Debug, Debug,
#[command(hide = true)] #[command(hide = true)]
None, None,
@ -60,7 +65,7 @@ impl Command {
.unwrap(); .unwrap();
info!("Parsing package..."); info!("Parsing package...");
trace!("Fetching package: {}", package_identifier); trace!("Fetching package: {:?}", package_identifier);
let mut pkg = Package::try_fetch(package_identifier.clone()).unwrap(); let mut pkg = Package::try_fetch(package_identifier.clone()).unwrap();
debug!("manifest size: {}kb", pkg.pkgfile.manifest.len() / 1024); debug!("manifest size: {}kb", pkg.pkgfile.manifest.len() / 1024);
debug!("files size: {}kb", pkg.pkgfile.data.len() / 1024); debug!("files size: {}kb", pkg.pkgfile.data.len() / 1024);
@ -107,6 +112,23 @@ impl Command {
Command::Update => { Command::Update => {
error!("Update is not yet implemented."); 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 => { Command::Debug => {
trace!("Trace message.\nWith newline."); trace!("Trace message.\nWith newline.");
debug!("Debug message.\nWith newline."); debug!("Debug message.\nWith newline.");
@ -124,10 +146,6 @@ impl Command {
.unwrap(); .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!("");
info!( info!(
"PKGR_LOG_LEVEL: {}", "PKGR_LOG_LEVEL: {}",