aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--primrose/Cargo.toml1
-rw-r--r--primrose/crates/candelabra-cli/Cargo.toml11
-rw-r--r--primrose/crates/candelabra-cli/src/main.rs14
-rw-r--r--primrose/crates/candelabra-cli/src/paths.rs45
4 files changed, 71 insertions, 0 deletions
diff --git a/primrose/Cargo.toml b/primrose/Cargo.toml
index 8dd7149..425cd54 100644
--- a/primrose/Cargo.toml
+++ b/primrose/Cargo.toml
@@ -3,6 +3,7 @@ resolver = "2"
members = [
"crates/primrose/",
"crates/primrose-library/",
+ "crates/candelabra-cli"
]
[workspace.dependencies]
diff --git a/primrose/crates/candelabra-cli/Cargo.toml b/primrose/crates/candelabra-cli/Cargo.toml
new file mode 100644
index 0000000..11baffa
--- /dev/null
+++ b/primrose/crates/candelabra-cli/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "candelabra-cli"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+log = { workspace = true }
+env_logger = { workspace = true }
+primrose = { path = "../primrose" } \ No newline at end of file
diff --git a/primrose/crates/candelabra-cli/src/main.rs b/primrose/crates/candelabra-cli/src/main.rs
new file mode 100644
index 0000000..9a5f140
--- /dev/null
+++ b/primrose/crates/candelabra-cli/src/main.rs
@@ -0,0 +1,14 @@
+use log::info;
+
+use crate::paths::Paths;
+
+mod paths;
+
+fn main() {
+ env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
+
+ let paths = Paths::default();
+ info!("Using source dir: {:?}", &paths.base);
+
+ dbg!(primrose::library_specs::read_lib_files(&paths.library_src).unwrap());
+}
diff --git a/primrose/crates/candelabra-cli/src/paths.rs b/primrose/crates/candelabra-cli/src/paths.rs
new file mode 100644
index 0000000..9f1b520
--- /dev/null
+++ b/primrose/crates/candelabra-cli/src/paths.rs
@@ -0,0 +1,45 @@
+use std::{
+ env,
+ path::{Path, PathBuf},
+};
+
+pub struct Paths {
+ pub base: PathBuf,
+ pub library_src: PathBuf,
+}
+
+impl Paths {
+ fn from_base(base: PathBuf) -> Self {
+ Paths {
+ library_src: Self::library_src(&base),
+ base,
+ }
+ }
+
+ fn library_src(base: &Path) -> PathBuf {
+ base.join("crates").join("primrose-library").join("src")
+ }
+}
+
+impl Default for Paths {
+ fn default() -> Self {
+ let path = if let Ok(var) = env::var("CANDELABRA_SRC_DIR") {
+ var.into()
+ } else {
+ // Most the time this won't work, but it's worth a shot.
+ let mut path = PathBuf::from(file!());
+ path.pop(); // main.rs
+ path.pop(); // src
+ path.pop(); // candelabra-cli
+ path.pop(); // crates
+ if path.components().count() == 0 {
+ path.push(".");
+ }
+ path
+ };
+
+ Paths::from_base(path.canonicalize().expect(
+ "candelabra source directory not found. please specify it with CANDELABRA_SRC_DIR",
+ ))
+ }
+}