aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar BanceDev 2026-02-27 23:52:28 -0500
committerGravatar BanceDev 2026-02-27 23:52:28 -0500
commit0c70155f2c30fa84802f6dc9b893716878437295 (patch)
treee8950e9e6dc7a47ac8a5b909e9a54be10a5afccc /src
parentupgrade function added (diff)
added show command
Diffstat (limited to 'src')
-rw-r--r--src/action.rs11
-rw-r--r--src/config.rs27
2 files changed, 34 insertions, 4 deletions
diff --git a/src/action.rs b/src/action.rs
index f8504f2..735516e 100644
--- a/src/action.rs
+++ b/src/action.rs
@@ -1,4 +1,4 @@
-use crate::config::{self, ConfigCommand, TEMP_CONFIG_PATH, create_config};
+use crate::config::{self, Config, ConfigCommand, TEMP_CONFIG_PATH, create_config};
use crate::util::{dir_size, get_editor, open_in_editor, pull_repo, yn_prompt};
use git2::Repository;
use std::fs;
@@ -72,7 +72,7 @@ impl Action {
Action::List => list(),
Action::Search { term } => Ok(search(term)),
Action::Clean { packages } => clean(packages),
- Action::Show { package } => Ok(show(package)),
+ Action::Show { package } => show(package),
Action::Version => Ok(version()),
}
}
@@ -374,8 +374,11 @@ fn clean(packages: Vec<String>) -> Result<(), String> {
Ok(())
}
-fn show(package: String) {
- println!("showing {}", package);
+fn show(package: String) -> Result<(), String> {
+ let config_path = PathBuf::from(BASE_CONFIG_PATH).join(format!("{package}.toml"));
+ let config = Config::new(&config_path).ok_or("config not found".to_string())?;
+ config.log_config();
+ Ok(())
}
fn version() {
diff --git a/src/config.rs b/src/config.rs
index 8e3437c..bb21f09 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -43,6 +43,33 @@ impl Config {
let config: Config = toml::from_str(&contents).expect("failed to parse config");
Some(config)
}
+
+ pub fn log_config(self) {
+ if let Some(update) = &self.update {
+ println!("update: {}", update);
+ }
+
+ if let Some(deps) = &self.dependencies {
+ println!("dependencies: {:?}", deps);
+ }
+
+ if let Some(hooks) = &self.hooks {
+ println!("hooks:");
+
+ for (name, value) in [
+ ("build", &hooks.build),
+ ("install", &hooks.install),
+ ("uninstall", &hooks.uninstall),
+ ("post_install", &hooks.post_install),
+ ("post_uninstall", &hooks.post_uninstall),
+ ("clean", &hooks.clean),
+ ] {
+ if let Some(val) = value {
+ println!(" {}: {}", name, val);
+ }
+ }
+ }
+ }
}
pub fn create_config(package: &str) -> Result<(), String> {