# π String Pipeline
[](https://crates.io/crates/string_pipeline)
[](https://docs.rs/string_pipeline)
[](https://github.com/lalvarezt/string_pipeline/actions)
[](https://github.com/lalvarezt/string_pipeline/blob/main/LICENSE)
A string transformation library and CLI tool for Rust. Chain operations like split, join, replace, and filter using template syntax.
---
## π Table of Contents
- [π Why String Pipeline?](#-why-string-pipeline)
- [β‘ Examples](#-examples)
- [π Installation](#-installation)
- [π Quick Start](#-quick-start)
- [π§ͺ Testing](#-testing)
- [β‘ Performance & Benchmarking](#-performance--benchmarking)
- [π Documentation](#-documentation)
- [π€ Contributing](#-contributing)
- [π License](#-license)
## π Why String Pipeline?
**Transform complex text processing into simple, readable templates:**
```bash
# Traditional approach (multiple commands)
grep -o '@*' | \
tr -d '@' | \
sort | \
tr '\n' ','
# String Pipeline (single template)
```
### β¨ Key Features
- **π Chainable Operations**: Pipe operations together naturally
- **πΊοΈ Powerful Mapping**: Apply sub-pipelines to each list item
- **π Regex Support**: sed-like patterns for complex transformations
- **π Debug Mode**: Step-by-step operation visualization
## β‘ Examples
### π₯ Basic Transformations
```bash
# Extract middle items from list
string-pipeline "{split:,:1..3}" "a,b,c,d,e"
# Output: "b,c"
# Clean and format names
# Extract numbers and pad with zeros
```
### π§ Advanced Processing
```bash
# Filter files, format as list
# Extract domains from URLs
# Debug complex processing
```
## π Installation
### π¦ CLI Tool
```bash
# Install from crates.io
cargo install string_pipeline
# Or build from source
git clone https://github.com/lalvarezt/string_pipeline.git
cd string_pipeline
cargo install --path .
```
### π Rust Library
Add to your `Cargo.toml`:
```toml
[dependencies]
string_pipeline = "0.13.0"
```
## π Quick Start
### π» CLI Usage
```bash
# With argument
string-pipeline '{template}' "input string"
# With stdin
# Debug mode
# DEBUG: βββ π MULTI-TEMPLATE START
# DEBUG: βββ Template: "{!split:,:..|map:{upper}}"
# DEBUG: βββ β‘οΈ Input: "hello,world"
# DEBUG: βββ 1 sections to process (literal: 0, template: 1)
# DEBUG: β
# DEBUG: βββ π SECTION 1/1: [template: split(',',..) | map { operations: [upper] }]
# DEBUG: βββ πΎ CACHE MISS Computing and storing result
# DEBUG: β
# DEBUG: βββ π Main Pipeline
# DEBUG: β βββ π PIPELINE START: 2 operations
# DEBUG: β βββ β‘οΈ Input: String(hello,world)
# DEBUG: β βββ 1. Split(',')
# DEBUG: β βββ 2. Map(1)
# DEBUG: β βββ βοΈ Step 1: Split
# DEBUG: β β βββ β‘οΈ Input: String(hello,world)
# DEBUG: β β βββ π― Result: List["hello", "world"]
# DEBUG: β β βββ Time: 332.41Β΅s
# DEBUG: β βββ βοΈ Step 2: Map
# DEBUG: β β βββ β‘οΈ Input: List["hello", "world"]
# DEBUG: β β βββ π― Result: String(processing...)
# DEBUG: β β βββ Time: 0ns
# DEBUG: β β βββ ποΈ Item 1/2
# DEBUG: β β β βββ β‘οΈ Input: "hello"
# DEBUG: β β β βββ π Sub-Pipeline
# DEBUG: β β β β βββ π§ SUB-PIPELINE START: 1 operations
# DEBUG: β β β β βββ β‘οΈ Input: String(hello)
# DEBUG: β β β β βββ βοΈ Step 1: Upper
# DEBUG: β β β β β βββ β‘οΈ Input: String(hello)
# DEBUG: β β β β β βββ π― Result: String(HELLO)
# DEBUG: β β β β β βββ Time: 875ns
# DEBUG: β β β β βββ β
SUB-PIPELINE COMPLETE
# DEBUG: β β β β βββ π― Result: String(HELLO)
# DEBUG: β β β β βββ Time: 16.37Β΅s
# DEBUG: β β β βββ Output: "HELLO"
# DEBUG: β β βββ ποΈ Item 2/2
# DEBUG: β β β βββ β‘οΈ Input: "world"
# DEBUG: β β β βββ π Sub-Pipeline
# DEBUG: β β β β βββ π§ SUB-PIPELINE START: 1 operations
# DEBUG: β β β β βββ β‘οΈ Input: String(world)
# DEBUG: β β β β βββ βοΈ Step 1: Upper
# DEBUG: β β β β β βββ β‘οΈ Input: String(world)
# DEBUG: β β β β β βββ π― Result: String(WORLD)
# DEBUG: β β β β β βββ Time: 93ns
# DEBUG: β β β β βββ β
SUB-PIPELINE COMPLETE
# DEBUG: β β β β βββ π― Result: String(WORLD)
# DEBUG: β β β β βββ Time: 15.749Β΅s
# DEBUG: β β β βββ Output: "WORLD"
# DEBUG: β β βββ π¦ MAP COMPLETED: 2 β 2 items
# DEBUG: β βββ β
PIPELINE COMPLETE
# DEBUG: β βββ π― Result: List["HELLO", "WORLD"]
# DEBUG: β βββ Time: 457.193Β΅s
# DEBUG: β
# DEBUG: βββ π β
MULTI-TEMPLATE COMPLETE
# DEBUG: βββ π― Final result: "HELLO,WORLD"
# DEBUG: βββ Total execution time: 568.533Β΅s
# DEBUG: βββ Cache stats: 0 regex patterns, 1 split operations cached
# HELLO,WORLD
```
### π¦ Library Usage
```rust
use string_pipeline::Template;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let template = Template::parse("{split:,:..|map:{upper}|join:-}")?;
let result = template.format("hello,world,rust")?;
println!("{}", result); // "HELLO-WORLD-RUST"
Ok(())
}
```
## π§ͺ Testing
```bash
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run benchmarks
cargo bench
```
## β‘ Performance & Benchmarking
String Pipeline includes simple benchmarking tools for measuring performance:
```bash
# Build the benchmark tool
cargo build --release --bin bench
# Run benchmarks (1000 iterations)
./target/release/bench
# Quick performance check (100 iterations)
./target/release/bench --iterations 100
# Generate JSON for scripts
./target/release/bench --format json > benchmark_results.json
```
## π Documentation
[π Template System](docs/template-system.md)
[βοΈ CLI Options & Usage](docs/command-line-options.md)
[π Comprehensive Debug System Guide](docs/debug-system.md)
[π Performance Benchmarking Guide](docs/benchmarking.md)
## π€ Contributing
We welcome contributions! π
- π **Report bugs** via [GitHub Issues](https://github.com/lalvarezt/string_pipeline/issues)
- π‘ **Suggest features** or improvements
- π§ **Submit pull requests**
## π License
This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
---
**β‘ Fast and composable string transformations made simple!**