diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 0000000..afc1474
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,14 @@
+[target.x86_64-apple-darwin]
+rustflags = [
+ "-C", "link-arg=-undefined",
+ "-C", "link-arg=dynamic_lookup",
+]
+
+[target.aarch64-apple-darwin]
+rustflags = [
+ "-C", "link-arg=-undefined",
+ "-C", "link-arg=dynamic_lookup",
+]
+
+[rust-analyzer]
+cargo.targetDir = "/tmp/rust-analyzer-target"
diff --git a/Cargo.lock b/Cargo.lock
index 6a093d8..9ba784e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -254,9 +254,18 @@ checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
[[package]]
name = "frork"
version = "0.1.0"
+dependencies = [
+ "frork-lib",
+ "mlua",
+]
+
+[[package]]
+name = "frork-cli"
+version = "0.1.0"
dependencies = [
"clap",
"color-eyre",
+ "frork-lib",
"mlua",
"regex",
"serde",
@@ -265,6 +274,10 @@ dependencies = [
"tracing-subscriber",
]
+[[package]]
+name = "frork-lib"
+version = "0.1.0"
+
[[package]]
name = "gimli"
version = "0.32.3"
@@ -366,6 +379,7 @@ dependencies = [
"either",
"erased-serde",
"mlua-sys",
+ "mlua_derive",
"num-traits",
"parking_lot",
"rustc-hash",
@@ -387,6 +401,17 @@ dependencies = [
"pkg-config",
]
+[[package]]
+name = "mlua_derive"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "465bddde514c4eb3b50b543250e97c1d4b284fa3ef7dc0ba2992c77545dbceb2"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "nu-ansi-term"
version = "0.50.3"
diff --git a/Cargo.toml b/Cargo.toml
index 4ce62ec..d9cffd0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,14 +1,3 @@
-[package]
-name = "frork"
-version = "0.1.0"
-edition = "2024"
-
-[dependencies]
-color-eyre = "*"
-clap = { version = "*", features = ["derive"] }
-mlua = { version = "*", features = ["lua54", "serde", "vendored"] }
-regex = "*"
-serde = { version = "*", features = ["derive"] }
-thiserror = "*"
-tracing = "*"
-tracing-subscriber = "*"
+[workspace]
+resolver = "3"
+members = ["frork-cli", "frork-lib", "frork-lua"]
diff --git a/frork-cli/Cargo.toml b/frork-cli/Cargo.toml
new file mode 100644
index 0000000..ea716e7
--- /dev/null
+++ b/frork-cli/Cargo.toml
@@ -0,0 +1,19 @@
+[package]
+name = "frork-cli"
+version = "0.1.0"
+edition = "2024"
+
+[[bin]]
+name = "frork"
+path = "src/main.rs"
+
+[dependencies]
+frork-lib = { path = "../frork-lib" }
+color-eyre = "*"
+clap = { version = "*", features = ["derive"] }
+mlua = { version = "*", features = ["lua54", "serde", "vendored"] }
+regex = "*"
+serde = { version = "*", features = ["derive"] }
+thiserror = "*"
+tracing = "*"
+tracing-subscriber = "*"
\ No newline at end of file
diff --git a/fennel-1.6.0.lua b/frork-cli/fennel-1.6.0.lua
similarity index 100%
rename from fennel-1.6.0.lua
rename to frork-cli/fennel-1.6.0.lua
diff --git a/src/assertions.rs b/frork-cli/src/assertions.rs
similarity index 100%
rename from src/assertions.rs
rename to frork-cli/src/assertions.rs
diff --git a/src/errors.rs b/frork-cli/src/errors.rs
similarity index 100%
rename from src/errors.rs
rename to frork-cli/src/errors.rs
diff --git a/src/lib.rs b/frork-cli/src/lib.rs
similarity index 100%
rename from src/lib.rs
rename to frork-cli/src/lib.rs
diff --git a/src/main.rs b/frork-cli/src/main.rs
similarity index 100%
rename from src/main.rs
rename to frork-cli/src/main.rs
diff --git a/src/utils.rs b/frork-cli/src/utils.rs
similarity index 100%
rename from src/utils.rs
rename to frork-cli/src/utils.rs
diff --git a/frork-lib/Cargo.toml b/frork-lib/Cargo.toml
new file mode 100644
index 0000000..fe7c53e
--- /dev/null
+++ b/frork-lib/Cargo.toml
@@ -0,0 +1,5 @@
+[package]
+name = "frork-lib"
+version = "0.1.0"
+edition = "2024"
+
diff --git a/frork-lib/src/lib.rs b/frork-lib/src/lib.rs
new file mode 100644
index 0000000..e69de29
diff --git a/frork-lua/Cargo.toml b/frork-lua/Cargo.toml
new file mode 100644
index 0000000..3e4b1b9
--- /dev/null
+++ b/frork-lua/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "frork"
+version = "0.1.0"
+edition = "2024"
+
+[lib]
+crate-type = ["cdylib"]
+
+[dependencies]
+frork-lib = { path = "../frork-lib" }
+mlua = { version = "*", features = ["lua54", "module"] }
diff --git a/frork-lua/src/lib.rs b/frork-lua/src/lib.rs
new file mode 100644
index 0000000..83298f4
--- /dev/null
+++ b/frork-lua/src/lib.rs
@@ -0,0 +1,37 @@
+use mlua::prelude::*;
+
+fn hello(name: Option<String>) -> String {
+ match name {
+ Some(name) => format!("Hello, {}!", name),
+ None => "Hello, World!".to_string(),
+ }
+}
+
+fn add(x: i64, y: i64) -> i64 {
+ x + y
+}
+
+#[mlua::lua_module]
+fn frork(lua: &Lua) -> LuaResult<LuaTable> {
+ let exports = lua.create_table()?;
+
+ // Simple hello function
+ exports.set(
+ "hello",
+ lua.create_function(|_, name: Option<String>| Ok(hello(name)))?,
+ )?;
+
+ // Simple add function
+ exports.set(
+ "add",
+ lua.create_function(|_, (x, y): (i64, i64)| Ok(add(x, y)))?,
+ )?;
+
+ // A table with some constants
+ let constants = lua.create_table()?;
+ constants.set("VERSION", "1.0.0")?;
+ constants.set("AUTHOR", "Frork Team")?;
+ exports.set("constants", constants)?;
+
+ Ok(exports)
+}
\ No newline at end of file