commit 4bbc5b8c22683341c0753700e55df8429d248c66
parent 40ef5a674a8bc250a2ce9eb42676007bf224f8f2
Author: triesap <tyson@radroots.org>
Date: Fri, 5 Jun 2026 18:11:55 -0700
repo: initialize tangle workspace
Diffstat:
7 files changed, 88 insertions(+), 10 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "tangle"
+version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
@@ -1,14 +1,14 @@
-[package]
-name = "tangle"
+[workspace]
+members = ["crates/tangle"]
+resolver = "2"
+
+[workspace.package]
version = "0.1.0"
edition = "2024"
authors = ["Radroots Authors"]
rust-version = "1.92.0"
license = "AGPL-3.0"
-description = "A SurrealDB-backend Nostr relay built for NIP-99 marketplaces"
-
-[workspace]
-resolver = "2"
-[lints.rust]
+[workspace.lints.rust]
+unsafe_code = "forbid"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }
diff --git a/crates/tangle/Cargo.toml b/crates/tangle/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "tangle"
+version.workspace = true
+edition.workspace = true
+authors.workspace = true
+rust-version.workspace = true
+license.workspace = true
+description = "The tangle Nostr relay runtime"
+readme = "../../README"
+
+[lints]
+workspace = true
diff --git a/crates/tangle/src/lib.rs b/crates/tangle/src/lib.rs
@@ -0,0 +1,28 @@
+#![forbid(unsafe_code)]
+
+pub const PACKAGE_NAME: &str = env!("CARGO_PKG_NAME");
+pub const PACKAGE_VERSION: &str = env!("CARGO_PKG_VERSION");
+
+pub fn version_output() -> String {
+ format!("{PACKAGE_NAME} {PACKAGE_VERSION}")
+}
+
+#[cfg(test)]
+mod tests {
+ use super::{PACKAGE_NAME, PACKAGE_VERSION, version_output};
+
+ #[test]
+ fn package_name_is_tangle() {
+ assert_eq!(PACKAGE_NAME, "tangle");
+ }
+
+ #[test]
+ fn package_version_matches_manifest() {
+ assert_eq!(PACKAGE_VERSION, "0.1.0");
+ }
+
+ #[test]
+ fn version_output_contains_package_and_version() {
+ assert_eq!(version_output(), "tangle 0.1.0");
+ }
+}
diff --git a/crates/tangle/src/main.rs b/crates/tangle/src/main.rs
@@ -0,0 +1,19 @@
+#![forbid(unsafe_code)]
+
+use std::env;
+use std::process::ExitCode;
+
+fn main() -> ExitCode {
+ let mut args = env::args().skip(1);
+ match args.next().as_deref() {
+ Some("--version") | Some("-V") => {
+ println!("{}", tangle::version_output());
+ ExitCode::SUCCESS
+ }
+ Some(_) => {
+ eprintln!("usage: tangle [--version]");
+ ExitCode::from(2)
+ }
+ None => ExitCode::SUCCESS,
+ }
+}
diff --git a/crates/tangle/tests/version.rs b/crates/tangle/tests/version.rs
@@ -0,0 +1,15 @@
+#![forbid(unsafe_code)]
+
+use std::process::Command;
+
+#[test]
+fn tangle_version_command_reports_package_version() {
+ let output = Command::new(env!("CARGO_BIN_EXE_tangle"))
+ .arg("--version")
+ .output()
+ .expect("run tangle --version");
+
+ assert!(output.status.success());
+ assert_eq!(String::from_utf8_lossy(&output.stdout), "tangle 0.1.0\n");
+ assert!(output.stderr.is_empty());
+}
diff --git a/src/main.rs b/src/main.rs
@@ -1,3 +0,0 @@
-#![forbid(unsafe_code)]
-
-fn main() {}