# π 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 powerful string transformation CLI tool and Rust library that makes complex text processing simple. Transform data using intuitive **template syntax** β chain operations like **split**, **join**, **replace**, **filter**, and **20+ others** in a single readable expression.
---
## π Table of Contents
- [π Why String Pipeline?](#-why-string-pipeline)
- [β‘ Quick Examples](#-quick-examples)
- [π Installation](#-installation)
- [π Quick Start](#-quick-start)
- [π Documentation](#-documentation)
- [π§ͺ Testing](#-testing)
- [π€ 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
- **π― Precise Control**: Python-like ranges with Rust syntax (`-2..`, `1..=3`)
- **πΊοΈ Powerful Mapping**: Apply sub-pipelines to each list item
- **π Regex Support**: sed-like patterns for complex transformations
- **π Debug Mode**: Step-by-step operation visualization
- **π₯ Flexible I/O**: CLI tool + embeddable Rust library
## β‘ Quick 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
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: PIPELINE START: 3 operations to apply
# DEBUG: Initial input: Str("apple Banana cherry Date")
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: STEP 1/3: Applying Split { sep: " ", range: Range(None, None, false) }
# DEBUG: Input: Str("apple Banana cherry Date")
# DEBUG: Result: List(4 items: ["apple", "Banana", "cherry", "Date"])
# DEBUG: Step completed in 425.1Β΅s
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: STEP 2/3: Applying Filter { pattern: "^[A-Z]" }
# DEBUG: Input: List(["apple", "Banana", "cherry", "Date"])
# DEBUG: Result: List(2 items: ["Banana", "Date"])
# DEBUG: Step completed in 287.6Β΅s
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: STEP 3/3: Applying Sort { direction: Desc }
# DEBUG: Input: List(["Banana", "Date"])
# DEBUG: Result: List(2 items: ["Date", "Banana"])
# DEBUG: Step completed in 156.3Β΅s
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: PIPELINE COMPLETE
# DEBUG: Total execution time: 1.2431ms
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# Date Banana
```
> π‘ **Want to see more?** Check out the [π Documentation](#-documentation) with 20+ operations and real-world examples!
## π 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.10.0"
```
## π Quick Start
### π» CLI Usage
```bash
# With argument
string-pipeline '{template}' "input string"
# With stdin
# Debug mode (shows each step)
# DEBUG: PIPELINE START: 2 operations to apply
# DEBUG: Initial input: Str("a,b,c")
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: STEP 1/2: Applying Split { sep: ",", range: Range(None, None, false) }
# DEBUG: Input: Str("a,b,c")
# DEBUG: Result: List(3 items: ["a", "b", "c"])
# DEBUG: Step completed in 342.7Β΅s
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: STEP 2/2: Applying Map { operations: [Upper] }
# DEBUG: Input: List(["a", "b", "c"])
# DEBUG: MAP OPERATION: Processing 3 items
# DEBUG: ββ Processing item 1 of 3 βββββββββββββ
# DEBUG: β Input: "a" β Output: "A"
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: ββ Processing item 2 of 3 βββββββββββββ
# DEBUG: β Input: "b" β Output: "B"
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: ββ Processing item 3 of 3 βββββββββββββ
# DEBUG: β Input: "c" β Output: "C"
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: MAP COMPLETED: 3 β 3 items
# DEBUG: Result: List(3 items: ["A", "B", "C"])
# DEBUG: Step completed in 15.2841ms
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# DEBUG: PIPELINE COMPLETE
# DEBUG: Total execution time: 18.7456ms
# DEBUG: βββββββββββββββββββββββββββββββββββββββββββββββ
# A,B,C
```
### π¦ 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(())
}
```
## π Documentation
π― **[π Template System](docs/template-system.md)**
π **[βοΈ CLI Options & Usage](docs/command-line-options.md)**
π **[π Comprehensive Debug System Guide](docs/debug-system.md)**
**Everything you need to master String Pipeline:**
- **ποΈ Template Syntax** - Structure, chaining, escaping rules
- **π Operations Reference** - 20+ operations with examples
- πͺ **Split & Join** - Parse and reassemble text
- βοΈ **Slice & Range** - Extract with Python-like indices
- π¨ **Transform** - Case, trim, pad, append/prepend
- π **Regex** - Pattern matching and replacement
- ποΈ **List Ops** - Filter, sort, unique, reverse
- πΊοΈ **Map** - Apply operations to each item
- **π― Range Specifications** - Negative indexing, edge cases
- **π‘οΈ Escaping Rules** - When and how to escape characters
- **π Debug Mode** - Visual operation debugging
- **π‘ Real-world Examples** - Data processing, log analysis, formatting
- **β οΈ Troubleshooting** - Common errors and best practices
## π§ͺ Testing
```bash
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run benchmarks
cargo bench
```
## π€ Contributing
We welcome contributions! π
- π **Report bugs** via [GitHub Issues](https://github.com/lalvarezt/string_pipeline/issues)
- π‘ **Suggest features** or improvements
- π§ **Submit pull requests**
π Please see our [comprehensive documentation](docs/template-system.md) for syntax details and examples.
## π License
This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
---
**β‘ Fast, composable string transformations made simple!**