From f8b31c4c8092a11e4ca3b19a3e662aa44282a2c3 Mon Sep 17 00:00:00 2001 From: Didier Date: Mon, 7 Aug 2023 04:27:14 +0200 Subject: [PATCH] feat: debug command only in debug mode --- pkgr/src/commands.rs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/pkgr/src/commands.rs b/pkgr/src/commands.rs index 01a1619..9440645 100644 --- a/pkgr/src/commands.rs +++ b/pkgr/src/commands.rs @@ -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: {}",