Skip to content

feat(tx3c): select built-in templates by name with --template - #361

Merged
scarmuega merged 1 commit into
mainfrom
codegen/template-names
Sep 26, 2026
Merged

scarmuega merged 1 commit into
mainfrom
codegen/template-names

Conversation

@scarmuega

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #360, before any release ships --language. A template is one use case in one language, such as rust-client. It is therefore the single dimension tx3c codegen selects. Language and use case are not separate flags.

  • One flag. --template <name-or-dir> replaces the unreleased --language. A bare name, with no path separator and no leading ., selects a built-in template when one has that name. Anything else is a custom template directory, exactly as before, so every released caller of --template <dir> keeps working. ./name forces a directory.
  • Built-in templates are ts-client, rust-client, python-client and go-client. The names match trix's plugin names, so trix can pass them straight through. Their files move to bin/tx3c/templates/<name>/ and are listed in a name-keyed registry, codegen/templates.rs.
  • Backends don't own templates. A template picks its language backend through the helpers it calls, for example declarations tii "rust". Backend::client_templates() is removed.
  • Adding a use case. A new use case in an existing language, such as a Rust server stub, is one template directory plus one registry entry. The CLI doesn't change.
tx3c codegen --tii p.tii --template rust-client --output out   # built-in
tx3c codegen --tii p.tii --template ./my-server --output out   # custom directory

Tests and CI

  • A unit test fails if the registry and the template directories disagree. New tests cover name and path resolution and both error messages.
  • Golden output moves from expected/<language> to expected/<name> with identical content.
  • The codegen compile CI job now runs per template.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test -p tx3c --locked, with 25 unit tests plus the golden corpus.
  • Locally, codegen-compile-check.sh passed for rust-client and ts-client against the published 0.15.0 SDKs. CI covers python-client and go-client.

tx3-lang/trix#132 is updated to pass --template <plugin name> for built-in plugins.

🤖 Generated with Claude Code

A template is one use case in one language, such as `rust-client`, so
it is the single thing `tx3c codegen` selects. Replace the unreleased
`--language` flag with `--template <name-or-dir>`:

- A bare name (no path separator, no leading `.`) selects a built-in
  template when one has that name. Anything else is a custom template
  directory, exactly as before, so every released caller keeps working.
- Built-in templates are ts-client, rust-client, python-client, and
  go-client, matching trix's plugin names. Their files move to
  bin/tx3c/templates/<name>/ and are listed in a name-keyed registry
  (codegen/templates.rs). Language backends no longer own templates;
  a template picks its backend through the helpers it calls.
- Golden output moves to expected/<name>/, and the codegen compile CI
  job runs per template.

A new use case in an existing language, such as a server stub, is a new
template directory and registry entry, with no CLI change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant