parsm - Parse 'Em - An 'everything' parser, Sedder, Awkker, Grokker, Grepper
Parsm is the powerful command-line tool that understands structured text better than sed, awk, grep or grok.
Overview
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.
0.8.3 removed a legacy fallback parser that could silently mis-parse certain filter/template expressions; parsing now runs entirely through one grammar. See CHANGELOG.md for the full list of fixes.
Installation
From crates.io
From source
Or build from source:
Quick Start
# Basic usage
# Examples
# Extract a field
|
# Nested fields
|
# Filtering
|
# Filter and format
|
# Read input from a file instead of stdin
Supported Formats
- JSON
- CSV
- YAML
- TOML
- Logfmt
- Plain Text
Syntax Reference
See doc/syntaxfieldselector.md for the full field-selection design rationale and syntax walkthrough.
Filters
- Comparison:
==,!=,<,<=,>,>= - String ops:
*=(contains),^=(starts with),$=(ends with),~=(regex match) - Boolean logic:
&&,||,! - Truthy check:
field?
Examples:
&&
Templates
- Variables:
[${name}]or$name - Literal:
[name]
Example:
Field Selectors
- Simple:
name - Nested:
user.email - Quoted (special chars):
'special-field' - CSV/Text:
field_0,word_0
Examples
JSON/YAML/TOML
|
|
CSV
|
Logs
|
CLI
)
)
; )
Comparison with Other Tools
| 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 |
Development
- Build:
cargo build - Test:
cargo test - Lint:
cargo fmt && cargo clippy
Contributing
- Fork repository
- Create feature branch
- Write tests and code
- Run tests and lint checks
- Submit a pull request
Crates.io
License
See LICENSE.
Changelog
See CHANGELOG.md.
Examples
# Basic filtering - outputs original input when filter matches
|
# Output: {"name": "Alice", "age": 30}
# Filtering with custom template
|
# Output: Alice is 30
# Access original input in templates with ${0}
|
# Output: Original: {"name": "Alice", "age": 30}, Name: Alice