cargo-tupa-0.9.0 is not a library.
cargo-tupa
Cargo subcommand for Tupã pipelines — typecheck, format, lint, test, and execute your policies.
Installation
After installation, cargo tupa will be available as a Cargo subcommand.
Quick Start
1. Create a new project from template
# or locally:
2. Develop your pipeline
Edit src/lib.rs:
use pipeline;
use Executor;
pipeline!
3. Build & Check
4. Run
# With a binary target (default)
# With a specific example
# With a specific binary target
# With JSON input from environment variable
TUPA_INPUT='{"amount":1000.0,"risk_score":0.5}'
# With JSON input from file
# With JSON from stdin
|
# Parallel execution ( Tokio runtime required in your binary )
TUPA_PARALLEL=1
Your src/main.rs (or example binary) should read the TUPA_INPUT environment variable:
use env;
let input: Input = if let Ok = var else ;
Or read from stdin if TUPA_INPUT not set:
let mut buffer = Stringnew;
stdin.read_to_string.ok;
let input: Input = if buffer.is_empty else ;
Subcommands
| Command | Description |
|---|---|
cargo tupa check |
Validate the pipeline! macro (runs cargo check) |
cargo tupa run |
Execute a pipeline binary or example with JSON input |
cargo tupa test |
Run tests (including example pipelines) |
cargo tupa lint |
Lint .tp legacy files and surface Rust warnings |
cargo tupa fmt |
Format legacy .tp source files |
cargo tupa plugin new [FILENAME] |
Generate a plugin scaffold for dynamic step functions |
Run Examples (Workspace)
# From workspace root, run an example from tupa-engine
# With input and parallel mode
# Test all examples
# Check the engine examples (Rust DSL)
How It Works
- check: Delegates to
cargo check --message-format=json, filters Tupã macro errors. - run: Spawns
cargo run --exampleor--binwithTUPA_INPUTset; your binary callsExecutor::runorExecutor::run_parallel. Reads stdin if--inputnot provided. - test: Runs
cargo test --examplesto validate example pipelines. - lint: Scans for
.tpfiles and runstupa-lint; also showscargo checkwarnings. - fmt: Calls
tupa-fmton all.tpfiles found in the project.
Project Template
The tupa-template crate provides a complete scaffold:
Includes:
src/lib.rswith a sample pipelinesrc/main.rsintegrating withcargo-tupa runandTUPA_INPUTCargo.tomlwith dependencies:tupa-core,tupa-engine,serde,tokio- README with usage instructions
Notes
cargo tupaworks on the current Cargo package; use-m/--manifest-pathto point elsewhere.- Parallel execution requires Tokio runtime (
#[tokio::main]) and step-levelproduces/requiresannotations. - For
.tplegacy files, usecargo tupa fmtandcargo tupa lint(migration to Rust DSL recommended). cargo tupa run --input <file>reads JSON from file; falls back toTUPA_INPUTthen stdin.cargo tupa testrunscargo test --examples, ensuring pipeline unit tests pass.
Examples
# Check the engine examples (Rust DSL)
# Run fraud_complete example with custom input and parallel mode
# Lint all .tp files in workspace
Plugin Development
Create a new dynamic plugin scaffold:
This generates a template my_plugin.rs that exports two C symbols (_tupa_plugin_name, _tupa_plugin_register) and a step function my_step. Build it as a cdylib:
# produces target/release/libmy_plugin.so (or .dll/.dylib)
Load the plugin in your pipeline using tupa_plugin::PluginManager:
use pipeline;
use Executor;
use PluginManager;
let mut pm = new;
pm.load_plugin?;
// In a step:
pipeline!
For more details, see the tupa-plugin crate documentation.
0.9.0 — API may change before 1.0.