Crates.io | parsm |
lib.rs | parsm |
version | 0.8.2 |
created_at | 2025-07-01 14:51:08.03258+00 |
updated_at | 2025-07-06 23:22:08.115476+00 |
description | Multi-format data processor that understands structured text better than sed or awk. Supports JSON, CSV, YAML, TOML, logfmt, and plain text with powerful filtering and templating. |
homepage | |
repository | https://github.com/jac18281828/parsm |
max_upload_size | |
id | 1733295 |
size | 1,258,633 |
Parsm is the powerful command-line tool that understands structured text better than sed
, awk
, grep
or grok
.
parsm
automatically detects and parses multiple data formats (JSON, CSV, YAML, TOML, logfmt, and plain text) and provides powerful filtering and templating capabilities through an intuitive syntax.
By default, parsm outputs the original input when a filter matches. For custom output formatting, use templates.
cargo install parsm
cargo install --path .
Or build from source:
git clone <repository-url>
cd parsm
cargo build --release
./target/release/parsm --examples
# Basic usage
parsm [FILTER] [TEMPLATE]
# Examples
parsm --examples
# Extract a field
echo '{"name": "Alice"}' | parsm 'name'
# Nested fields
echo '{"user": {"email": "alice@example.com"}}' | parsm 'user.email'
# Filtering
echo '{"age": 30}' | parsm 'age > 25'
# Filter and format
echo '{"name": "Alice", "age": 30}' | parsm 'age > 25 [${name} is ${age}]'
Flag | Format |
---|---|
--json |
JSON |
--yaml |
YAML |
--csv |
CSV |
--toml |
TOML |
--logfmt |
logfmt |
--text |
Plain Text |
==
, !=
, <
, <=
, >
, >=
*=
(contains), ^=
(starts with), $=
(ends with), ~=
(regex match)&&
, ||
, !
field?
Examples:
name == "Alice" && age > 25
email ~ "@example.com"
user.active?
[${name}]
or $name
[name]
Example:
parsm 'age > 25 [${name} is ${age}]'
name
user.email
'special-field'
field_0
, word_0
cat Cargo.toml | parsm 'package.name'
echo '{"user": {"email": "alice@example.com"}}' | parsm 'user.email'
echo 'Alice,30,Engineer' | parsm 'field_1 > "25" [${1} (${2})]'
echo 'level=error msg="DB error"' | parsm 'level == "error" [${msg}]'
parsm [OPTIONS] [FILTER] [TEMPLATE]
Options:
--examples Show usage examples
-h, --help Show help
-V, --version Show version
Feature | parsm | jq | awk | sed |
---|---|---|---|---|
Multi-format | ✅ JSON, CSV, YAML, TOML, logfmt, text | JSON only | Text | Text |
Auto-detection | ✅ Automatic | ❌ Manual | ❌ Manual | ❌ Manual |
Field extraction | ✅ Simple name syntax |
✅ .name syntax |
Limited | ❌ No |
Simple syntax | ✅ Low | Medium | Complex | Medium |
cargo build
cargo test
cargo fmt && cargo clippy
See LICENSE.
See CHANGELOG.md.
# Basic filtering - outputs original input when filter matches
echo '{"name": "Alice", "age": 30}' | parsm 'age > 25'
# Output: {"name": "Alice", "age": 30}
# Filtering with custom template
echo '{"name": "Alice", "age": 30}' | parsm 'age > 25 [${name} is ${age}]'
# Output: Alice is 30
# Access original input in templates with ${0}
echo '{"name": "Alice", "age": 30}' | parsm '[Original: ${0}, Name: ${name}]'
# Output: Original: {"name": "Alice", "age": 30}, Name: Alice