aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorGravatar BanceDev 2026-02-26 12:40:51 -0500
committerGravatar BanceDev 2026-02-26 12:40:51 -0500
commit8c411011aadfd96e7189366f20dda87b26a50cbf (patch)
tree766b0d2e6d75c63c3fca1ffc0d3359064e83c0fe /src/config.rs
parentupdates to add, remove and list (diff)
add build support
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..f168b27
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,25 @@
+use serde::Deserialize;
+use std::fs;
+use std::path::Path;
+
+#[derive(Deserialize)]
+pub struct Config {
+ pub update: Option<String>,
+ pub build: Option<String>,
+ pub install: Option<String>,
+ pub dependencies: Option<Vec<String>>,
+}
+
+impl Config {
+ pub fn new<P: AsRef<Path>>(filepath: P) -> Option<Self> {
+ let contents = match fs::read_to_string(filepath) {
+ Ok(c) => c,
+ Err(_) => {
+ eprintln!("no package config found");
+ return None;
+ }
+ };
+ let config: Config = toml::from_str(&contents).expect("failed to parse config");
+ Some(config)
+ }
+}