Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ categories = ["text-processing", "command-line-utilities"]
[dependencies]
regex = "1"
clap = { version = "4", features = ["derive"] }
pest = "2.8"
pest_derive = "2.8"
66 changes: 26 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
# String Template Processor

[![Crates.io](https://img.shields.io/crates/v/string_pipeline.svg)](https://crates.io/crates/string_pipeline)
[![Docs.rs](https://docs.rs/string_pipeline/badge.svg)](https://docs.rs/string_pipeline)
[![CI](https://github.com/lalvarezt/string_pipeline/actions/workflows/release.yml/badge.svg)](https://github.com/lalvarezt/string_pipeline/actions)
[![License](https://img.shields.io/crates/l/string_pipeline.svg)](https://github.com/lalvarezt/string_pipeline/blob/main/LICENSE)

---

A flexible, composable string transformation CLI tool and library for Rust originally created as a parser for [television](https://github.com/alexpasmantier/television). It allows you to chain operations like split, join, slice, replace, case conversion, trim, and more, using a concise template syntax.

## Use Cases

- **Data extraction**: Parse CSV, logs, or structured text
- **Text transformation**: Clean and format strings in pipelines
- **File processing**: Extract parts of filenames or paths
- **Configuration parsing**: Process environment variables or config files
- **Shell scripting**: Quick text manipulation in scripts

## Features

- **Composable operations**: Chain multiple string operations in a single template.
Expand All @@ -16,7 +31,17 @@ A flexible, composable string transformation CLI tool and library for Rust origi
- **Stdin support**: Read input from stdin when no input argument is provided.
- **Tested**: Comprehensive test suite.

## Usage
## 📦 Crate

You can find this crate on [crates.io](https://crates.io/crates/string_pipeline):

```toml
[dependencies]
string_pipeline = "0.3.0"
```

## 🚀 Usage


### As a CLI

Expand Down Expand Up @@ -139,33 +164,6 @@ echo "2023-01-01 ERROR Failed to connect" | cargo run -- "{split: :1..:join: :lo
# Output: error failed to connect
```

## Library Usage

Add to your `Cargo.toml`:

```toml
[dependencies]
clap = "4"
regex = "1"
```

Use in your code:

```rust
use your_crate::process;

let result = process("foo,bar,baz", "{split:,:1:upper}").unwrap();
assert_eq!(result, "BAR");

// Chain multiple operations
let result = process(" hello world ", "{trim:split: :join:_:upper}").unwrap();
assert_eq!(result, "HELLO_WORLD");

// Work with ranges
let result = process("a,b,c,d,e", "{split:,:1..=3:join:-}").unwrap();
assert_eq!(result, "b-c-d");
```

## Error Handling

The tool provides helpful error messages for common issues:
Expand All @@ -190,18 +188,6 @@ cargo run -- "{replace:s/[/replacement/}" "test"
cargo test
```

## Use Cases

- **Data extraction**: Parse CSV, logs, or structured text
- **Text transformation**: Clean and format strings in pipelines
- **File processing**: Extract parts of filenames or paths
- **Configuration parsing**: Process environment variables or config files
- **Shell scripting**: Quick text manipulation in scripts

## License

MIT

---

**Enjoy fast, composable string transformations!**
Expand Down
Loading