diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..234a9a3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "matcha" +version = "0.1.0" +edition = "2021" + +[[bin]] +name = "matcha" +path = "src/main.rs" + +[dependencies] +clap = { version = "4", features = ["derive"] } +include_dir = "0.7" +tree-sitter = "0.22" +tree-sitter-typescript = "0.21" + +[dev-dependencies] +assert_cmd = "2" +predicates = "3" +tempfile = "3" diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..f26f88b --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,33 @@ +use clap::{Parser, Subcommand}; + +#[derive(Parser)] +#[command(name = "matcha", about = "green-tea CLI")] +pub struct Cli { + #[command(subcommand)] + pub command: Command, +} + +#[derive(Subcommand)] +pub enum Command { + /// Scaffold a new project + New { + name: String, + #[arg(long)] + template_url: Option, + }, + /// Detect the runtime and run the project in watch mode + Run, + /// Generate a piece and auto-wire it into the module + Create { + #[arg(value_parser = ["module", "controller", "step"])] + kind: String, + name: String, + #[arg(long)] + check: bool, + }, + /// Add a capability to a controller + Add { + #[arg(value_parser = ["sse", "stream", "buffer"])] + capability: String, + }, +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..ec242eb --- /dev/null +++ b/src/main.rs @@ -0,0 +1,14 @@ +mod cli; + +use clap::Parser; +use cli::{Cli, Command}; + +fn main() { + let cli = Cli::parse(); + match cli.command { + Command::New { .. } => eprintln!("new: not yet implemented"), + Command::Run => eprintln!("run: not yet implemented"), + Command::Create { .. } => eprintln!("create: not yet implemented"), + Command::Add { .. } => eprintln!("add: not yet implemented"), + } +} diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 0000000..8547984 --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,16 @@ +use assert_cmd::Command; +use predicates::str::contains; + +#[test] +fn help_lists_all_subcommands() { + Command::cargo_bin("matcha").unwrap() + .arg("--help").assert().success() + .stdout(contains("new")).stdout(contains("run")) + .stdout(contains("create")).stdout(contains("add")); +} + +#[test] +fn new_requires_a_name() { + Command::cargo_bin("matcha").unwrap() + .arg("new").assert().failure(); // missing +}