Files
matcha/src/cli.rs
T
chrnx 5c8f72b409 feat(openapi): the OpenAPI document, and the paperwork the crate shipped without
`Cargo.toml` has declared `license = "MIT"` since the first release and the
published crate carried no license text, so anyone vendoring the source had the
claim without the grant. `LICENSE` is that text. `DCO` is the certificate the
README has been requiring a sign-off against without shipping, and
`CONTRIBUTING.md` says how — including that GitHub is a mirror of `main` and
tags, so a pull request there is carried upstream by a maintainer rather than
merged, which would put the two forges out of sync.

`CHANGELOG.md` reconstructs 26.7.0 and 26.8.0-beta.0 from their tags. The CLI
ships on its own version line, so the header says what that does and does not
mean about the core version a scaffold is pinned to, and each entry says when
that pin moved.

`matcha openapi` prints core's structural OpenAPI 3.1 for the route table —
`--title`, `--api-version`, `--out`. It reuses the entry resolution and the
generated-script runner that `graph` and `explain` already had, so it is the
same `app.ready()` that resolves the graph without booting providers. Structural
is the honest word: paths, methods and parameters come from the decorators, and
nothing invents a response schema.

The loose end from the capability table is closed. `cli.rs` still carried its own
copies of the `create` kinds and the `add` capabilities, so adding either meant
editing two files that could disagree — a value the parser accepts and the
dispatcher rejects. Both now read the list from the module that owns it, and the
three `create` piece kinds became rows in a table rather than near-identical
match arms, which also retires a `too_many_arguments` allow.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-05 16:01:49 -05:00

77 lines
2.3 KiB
Rust

use clap::builder::PossibleValuesParser;
use clap::{Parser, Subcommand};
use crate::{cmd_add, cmd_create};
#[derive(Parser)]
#[command(name = "matcha", version, 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<String>,
#[arg(long, default_value = "node", value_parser = ["node", "deno", "bun", "edge"])]
runtime: String,
},
/// 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 = PossibleValuesParser::new(cmd_create::kinds()))]
kind: String,
name: String,
#[arg(long)]
check: bool,
},
/// Check the project for the misconfigurations that fail confusingly
Doctor,
/// Print the dependency graph (Mermaid, DOT, or JSON)
Graph {
#[arg(long, default_value = "mermaid", value_parser = ["mermaid", "dot", "json"])]
format: String,
/// Entry file exporting `app` (default: src/app.ts, then src/main.ts)
#[arg(long)]
entry: Option<String>,
/// Write to this file instead of stdout
#[arg(long)]
out: Option<String>,
},
/// Print the structural OpenAPI 3.1 document for the route table
Openapi {
/// API title (default: core's own)
#[arg(long)]
title: Option<String>,
/// API version (default: core's own)
#[arg(long)]
api_version: Option<String>,
#[arg(long)]
entry: Option<String>,
#[arg(long)]
out: Option<String>,
},
/// Explain one route's chain, in execution order
Explain {
/// The route pattern as declared, e.g. /users/:id
route: String,
#[arg(long)]
entry: Option<String>,
#[arg(long)]
out: Option<String>,
},
/// Add a capability to a controller
Add {
#[arg(value_parser = PossibleValuesParser::new(cmd_add::names()))]
capability: String,
/// Which controller to edit (default: the only one in src/controllers)
#[arg(long)]
controller: Option<String>,
},
}