use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
use crate::cli::commands::{
asm::AsmCommands,
baseline::BaselineCommands,
blame::BlameArgs,
bulk::BulkCommands,
cache::CacheCommands,
capa::CapaCommands,
cmp::CmpCommands,
completions::CompletionsArgs,
config::ConfigCommands,
ctrl::CtrlCommands,
dev::DevCommands,
diff::DiffArgs,
dmm::DmmArgs,
dsm::DsmArgs,
export::ExportCommands,
feat::FeatCommands,
haz::HazCommands,
history::HistoryArgs,
import::ImportArgs,
init::InitArgs,
link::LinkCommands,
log::LogArgs,
lot::LotCommands,
mate::MateCommands,
ncr::NcrCommands,
proc::ProcCommands,
quote::QuoteCommands,
recent::RecentArgs,
report::ReportCommands,
req::ReqCommands,
risk::RiskCommands,
rslt::RsltCommands,
schema::SchemaCommands,
search::SearchArgs,
status::StatusArgs,
sup::SupCommands,
tags::TagsCommands,
test::TestCommands,
tol::TolCommands,
trace::TraceCommands,
validate::ValidateArgs,
where_used::WhereUsedArgs,
work::WorkCommands,
workflow::{
ApproveArgs, CheckArgs, RejectArgs, ReleaseArgs, ReviewCommands, SubmitArgs, TeamCommands,
},
};
const HELP_TEMPLATE: &str = "\
{before-help}{name} {version}
{about-with-newline}
{usage-heading} {usage}
PROJECT:
init Initialize a new Tessera project
status Show project status dashboard
validate Validate project files against schemas
REQUIREMENTS & RISKS:
req Requirement management (new, list, show, edit)
haz Hazard management (new, list, show, edit)
risk Risk/FMEA management (new, list, show, edit, summary)
VERIFICATION & VALIDATION:
test Test protocol management (new, list, show, edit)
rslt Test result management (new, list, show, edit)
BILL OF MATERIALS:
cmp Component management (new, list, show, edit)
asm Assembly management (new, list, show, edit, cost, mass)
PROCUREMENT:
quote Quote management (new, list, show, edit)
sup Supplier management (new, list, show, edit)
MANUFACTURING:
proc Manufacturing process management (new, list, show, edit)
ctrl Control plan item management (new, list, show, edit)
work Work instruction management (new, list, show, edit)
lot Production lot/batch management (new, list, show, step, complete)
dev Process deviation management (new, list, show, approve, expire)
QUALITY:
ncr Non-conformance report management (new, list, show, edit)
capa Corrective/preventive action management (new, list, show, edit)
TOLERANCE ANALYSIS:
feat Feature management - dimensional features on components
mate Mate management - 1:1 feature contacts with fit calculation
tol Tolerance stackup analysis (worst-case, RSS, Monte Carlo)
TRACEABILITY & REPORTS:
link Manage links between entities (add, remove, show)
trace Traceability queries (from, to, coverage)
dsm Design Structure Matrix for component interactions
dmm Domain Mapping Matrix for cross-entity analysis
where-used Find where an entity is used/referenced
report Generate engineering reports (rvm, fmea, bom, etc.)
VERSION CONTROL:
history View git history for an entity
blame View git blame for an entity
diff View git diff for an entity
baseline Baseline management (create, compare, list, changed)
WORKFLOW (opt-in):
submit Submit entities for review (creates PR)
approve Approve entities under review
reject Reject entities back to draft
release Release approved entities
review View pending reviews (list, summary)
team Team roster management (list, whoami, init, add, remove)
check Check entities meet approval requirements
INTERCHANGE:
export Export project data (sysml)
import Import entities from CSV or SysML files
UTILITIES:
bulk Bulk operations on multiple entities
cache Entity cache management (rebuild, sync, status, query)
config View and modify Tessera configuration (show, set, unset)
search Search across all entity types
recent Show recently modified entities
tags View and manage entity tags (list, show)
schema View entity field definitions, valid values, and link types
completions Generate shell completion scripts (bash, zsh, fish, powershell)
help Print this message or the help of the given subcommand(s)
OPTIONS:
{options}
{after-help}";
#[derive(Parser)]
#[command(name = "tdt")]
#[command(author, version, about = "Tessera - Engineering Artifact Management")]
#[command(
long_about = "Tessera is a Unix-style toolkit for managing engineering artifacts as plain text files under git version control. Visit https://tessera-engineering.com for documentation."
)]
#[command(propagate_version = true)]
#[command(help_template = HELP_TEMPLATE)]
#[command(subcommand_required = true)]
#[command(disable_help_subcommand = false)]
#[command(infer_subcommands = true)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
#[command(flatten)]
pub global: GlobalOpts,
}
#[derive(clap::Args, Clone, Debug)]
pub struct GlobalOpts {
#[arg(long, short = 'o', global = true, default_value = "auto")]
pub output: OutputFormat,
#[arg(long, short = 'q', global = true)]
pub quiet: bool,
#[arg(long, short = 'v', global = true)]
pub verbose: bool,
#[arg(long, global = true)]
pub project: Option<PathBuf>,
}
#[derive(Subcommand)]
pub enum Commands {
Init(InitArgs),
Status(StatusArgs),
Validate(ValidateArgs),
#[command(subcommand)]
Req(ReqCommands),
#[command(subcommand)]
Haz(HazCommands),
#[command(subcommand)]
Risk(RiskCommands),
#[command(subcommand)]
Test(TestCommands),
#[command(subcommand)]
Rslt(RsltCommands),
#[command(subcommand)]
Cmp(CmpCommands),
#[command(subcommand)]
Asm(AsmCommands),
#[command(subcommand)]
Quote(QuoteCommands),
#[command(subcommand)]
Sup(SupCommands),
#[command(subcommand)]
Proc(ProcCommands),
#[command(subcommand)]
Ctrl(CtrlCommands),
#[command(subcommand)]
Work(WorkCommands),
#[command(subcommand)]
Lot(LotCommands),
#[command(subcommand)]
Dev(DevCommands),
#[command(subcommand)]
Ncr(NcrCommands),
#[command(subcommand)]
Capa(CapaCommands),
#[command(subcommand)]
Feat(FeatCommands),
#[command(subcommand)]
Mate(MateCommands),
#[command(subcommand)]
Tol(TolCommands),
#[command(subcommand)]
Link(LinkCommands),
Log(LogArgs),
#[command(subcommand)]
Trace(TraceCommands),
Dsm(DsmArgs),
Dmm(DmmArgs),
WhereUsed(WhereUsedArgs),
#[command(subcommand)]
Report(ReportCommands),
History(HistoryArgs),
Blame(BlameArgs),
Diff(DiffArgs),
#[command(subcommand)]
Baseline(BaselineCommands),
Submit(SubmitArgs),
Approve(ApproveArgs),
Reject(RejectArgs),
Release(ReleaseArgs),
#[command(subcommand)]
Review(ReviewCommands),
#[command(subcommand)]
Team(TeamCommands),
Check(CheckArgs),
#[command(subcommand)]
Export(ExportCommands),
Import(ImportArgs),
#[command(subcommand)]
Bulk(BulkCommands),
#[command(subcommand)]
Cache(CacheCommands),
#[command(subcommand)]
Config(ConfigCommands),
Search(SearchArgs),
Recent(RecentArgs),
#[command(subcommand)]
Tags(TagsCommands),
#[command(subcommand)]
Schema(SchemaCommands),
Completions(CompletionsArgs),
}
#[derive(ValueEnum, Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum OutputFormat {
#[default]
Auto,
Yaml,
Tsv,
Json,
Csv,
Md,
Id,
#[value(name = "short-id")]
ShortId,
Path,
Dot,
Tree,
Table,
}