summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacksonfu14 <jackson@fashionunited.com>2025-11-06 08:38:39 +0100
committerJackson Moore <jacksonmoore@tuta.io>2025-11-06 08:38:39 +0100
commit743bf0f56e566f9d7b7671805a81704c3b7b14c2 (patch)
tree85c373ca4fa6dbb52d160538db3a924fbe4103e9
parente4c5409397e6e833984d221d63a62ea7bcb2c4a9 (diff)
feat: basic cli app
-rw-r--r--.gitignore6
-rw-r--r--Cargo.toml11
-rw-r--r--README.md17
-rw-r--r--morphology-cli/Cargo.toml12
-rw-r--r--morphology-cli/src/main.rs62
-rw-r--r--morphology/Cargo.toml6
6 files changed, 109 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 327b01d..82340c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,7 @@ notes
old
CLAUDE.md
.claude
-morphology/target/
-morphology/Cargo.lock
+
+# Rust workspace artifacts
+target/
+Cargo.lock
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..3561ccf
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,11 @@
+[workspace]
+resolver = "2"
+members = [
+ "morphology",
+ "morphology-cli",
+]
+
+[workspace.package]
+version = "0.1.0"
+edition = "2021"
+authors = ["Your Name <you@example.com>"]
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..08b9038
--- /dev/null
+++ b/README.md
@@ -0,0 +1,17 @@
+# Build everything
+cargo build --all
+
+# Build just the library
+cargo build -p meta_affine
+
+# Build just the CLI
+cargo build -p morphology-cli
+
+# Run tests
+cargo test --all
+
+# Run the generate command
+cargo run --bin generate 5
+
+# Install the CLI tool globally
+cargo install --path morphology-cli
diff --git a/morphology-cli/Cargo.toml b/morphology-cli/Cargo.toml
new file mode 100644
index 0000000..5e74a3f
--- /dev/null
+++ b/morphology-cli/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "morphology-cli"
+version.workspace = true
+edition.workspace = true
+authors.workspace = true
+
+[[bin]]
+name = "generate"
+path = "src/main.rs"
+
+[dependencies]
+meta_affine = { path = "../morphology" }
diff --git a/morphology-cli/src/main.rs b/morphology-cli/src/main.rs
new file mode 100644
index 0000000..30c9687
--- /dev/null
+++ b/morphology-cli/src/main.rs
@@ -0,0 +1,62 @@
+//! CLI tool to generate all valid meta-affine sequences of a given length.
+//!
+//! Usage: generate <length>
+//!
+//! Example:
+//! generate 5
+//!
+//! This will list all valid meta-affine sequences of length 5 and print the total count.
+
+use meta_affine::sequence::generate_all_sequences;
+use std::env;
+use std::process;
+
+fn main() {
+ // Parse command-line arguments
+ let args: Vec<String> = env::args().collect();
+
+ if args.len() != 2 {
+ eprintln!("Usage: {} <length>", args[0]);
+ eprintln!("\nGenerates all valid meta-affine sequences of the specified length.");
+ eprintln!("\nExample:");
+ eprintln!(" {} 5", args[0]);
+ process::exit(1);
+ }
+
+ let length: usize = match args[1].parse() {
+ Ok(n) => n,
+ Err(_) => {
+ eprintln!("Error: Length must be a positive integer");
+ eprintln!("Usage: {} <length>", args[0]);
+ process::exit(1);
+ }
+ };
+
+ if length == 0 {
+ println!("No valid sequences of length 0.");
+ println!("\nTotal sequences: 0");
+ return;
+ }
+
+ println!("Generating all valid meta-affine sequences of length {}...\n", length);
+
+ // Generate all sequences
+ let sequences = generate_all_sequences(length);
+
+ // Print each sequence
+ for (i, sequence) in sequences.iter().enumerate() {
+ print!("{}. [", i + 1);
+ for (j, value) in sequence.values().iter().enumerate() {
+ print!("{}", value);
+ if j < sequence.values().len() - 1 {
+ print!(", ");
+ }
+ }
+ println!("]");
+ }
+
+ // Print summary
+ println!("\n{}", "=".repeat(70));
+ println!("Total sequences of length {}: {}", length, sequences.len());
+ println!("{}", "=".repeat(70));
+}
diff --git a/morphology/Cargo.toml b/morphology/Cargo.toml
index fcbf7fc..1380a3b 100644
--- a/morphology/Cargo.toml
+++ b/morphology/Cargo.toml
@@ -1,8 +1,8 @@
[package]
name = "meta_affine"
-version = "0.1.0"
-edition = "2021"
-authors = ["Your Name <you@example.com>"]
+version.workspace = true
+edition.workspace = true
+authors.workspace = true
[lib]
name = "meta_affine"