]> quire.kejadlen.dev Git - quire.git/commitdiff
Absorb Config into Quire
authorAlpha Chen <alpha@kejadlen.dev>
Sun, 26 Apr 2026 03:51:47 +0000 (03:51 +0000)
committerAlpha Chen <alpha@kejadlen.dev>
Sun, 26 Apr 2026 14:19:45 +0000 (07:19 -0700)
Config was a thin wrapper around repos_dir. Quire now owns all
configuration directly and gains a config_path field, in
preparation for the global config loader.

Assisted-by: GLM-5.1 via pi
src/bin/quire/main.rs
src/config.rs [deleted file]
src/lib.rs
src/quire.rs

index 26d7f193a240dc0722641dc8cd3339c84ec0c2b6..9fe3e8a3061232c1b21ad084c566fbe928d27341 100644 (file)
@@ -4,7 +4,6 @@ use clap::{CommandFactory, Parser, Subcommand};
 use clap_complete::Shell;
 use miette::IntoDiagnostic;
 use miette::Result;
-use quire::Config;
 use quire::Quire;
 use tracing_subscriber::EnvFilter;
 use tracing_subscriber::fmt;
@@ -89,7 +88,7 @@ async fn main() -> Result<()> {
         return Ok(());
     };
 
-    let quire = Quire::new(Config::default());
+    let quire = Quire::default();
 
     match command {
         Commands::Serve => commands::serve::run(&quire).await?,
diff --git a/src/config.rs b/src/config.rs
deleted file mode 100644 (file)
index a4ad745..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-use std::path::PathBuf;
-
-/// Application configuration.
-#[derive(Debug, Clone)]
-pub struct Config {
-    /// Root directory containing bare Git repositories.
-    pub repos_dir: PathBuf,
-}
-
-impl Default for Config {
-    fn default() -> Self {
-        Self {
-            repos_dir: PathBuf::from("/var/quire/repos"),
-        }
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    #[test]
-    fn default_repos_dir() {
-        let config = Config::default();
-        assert_eq!(config.repos_dir, PathBuf::from("/var/quire/repos"));
-    }
-}
index 08f4448ee500d19315bcdfdb8adbc49597adf62d..a9610e24a987db730289d4ae22dc68f3d206019a 100644 (file)
@@ -1,10 +1,8 @@
-mod config;
 mod error;
 pub mod fennel;
 pub mod quire;
 pub mod secret;
 
-pub use config::Config;
 pub use error::Error;
 pub use error::Result;
 pub use quire::Quire;
index 6227fb258b379625330c8df179e7cd2dad1af45c..04c2277241106b97da4e6ee79e362cb52420ce34 100644 (file)
@@ -2,8 +2,6 @@ use std::path::{Path, PathBuf};
 
 use miette::{IntoDiagnostic, Result, ensure};
 
-use crate::config::Config;
-
 /// A resolved repository path.
 ///
 /// Created by `Quire::repo` after validating the name.
@@ -24,18 +22,28 @@ impl Repo {
 /// Application runtime context.
 ///
 /// Carries configuration and provides resolved paths to repositories.
-/// Commands receive a `&Quire` instead of threading `&Config` around.
+/// Commands receive a `&Quire` instead of threading config around.
 pub struct Quire {
-    config: Config,
+    repos_dir: PathBuf,
+    config_path: PathBuf,
 }
 
-impl Quire {
-    pub fn new(config: Config) -> Self {
-        Self { config }
+impl Default for Quire {
+    fn default() -> Self {
+        Self {
+            repos_dir: PathBuf::from("/var/quire/repos"),
+            config_path: PathBuf::from("/var/quire/config.fnl"),
+        }
     }
+}
 
+impl Quire {
     pub fn repos_dir(&self) -> &Path {
-        &self.config.repos_dir
+        &self.repos_dir
+    }
+
+    pub fn config_path(&self) -> &Path {
+        &self.config_path
     }
 
     /// Validate a repository name and return its resolved path.
@@ -45,13 +53,13 @@ impl Quire {
     pub fn repo(&self, name: &str) -> Result<Repo> {
         validate_repo_name(name)?;
         Ok(Repo {
-            path: self.config.repos_dir.join(name),
+            path: self.repos_dir.join(name),
         })
     }
 
     /// List all repository names under the repos directory.
     pub fn repos(&self) -> Result<impl Iterator<Item = String> + '_> {
-        let entries = fs_err::read_dir(&self.config.repos_dir).into_diagnostic()?;
+        let entries = fs_err::read_dir(&self.repos_dir).into_diagnostic()?;
 
         let mut repos: Vec<String> = Vec::new();
         for entry in entries {
@@ -62,7 +70,7 @@ impl Quire {
                 continue;
             }
 
-            let Ok(relative) = path.strip_prefix(&self.config.repos_dir) else {
+            let Ok(relative) = path.strip_prefix(&self.repos_dir) else {
                 continue;
             };
             let name = relative.to_string_lossy();
@@ -129,7 +137,14 @@ mod tests {
     use super::*;
 
     fn quire() -> Quire {
-        Quire::new(Config::default())
+        Quire::default()
+    }
+
+    #[test]
+    fn default_paths() {
+        let q = Quire::default();
+        assert_eq!(q.repos_dir(), Path::new("/var/quire/repos"));
+        assert_eq!(q.config_path(), Path::new("/var/quire/config.fnl"));
     }
 
     #[test]