braces
Convert file paths into compact braces expansion syntax.
Examples
use ;
// Basic usage
let paths = vec!;
let result = brace_paths?;
assert_eq!;
Stem Splitting
Factor out common character prefixes within path segments:
let config = BraceConfig ;
let paths = vec!;
let result = brace_paths?;
assert_eq!;
Segment Splitting
Control whether to create empty alternatives when one path is a prefix of another:
// Enabled (default) - creates empty alternative
let paths = vec!;
let result = brace_paths?;
assert_eq!;
// Disabled - keeps paths whole
let config = BraceConfig ;
let result = brace_paths?;
assert_eq!;
Sorting
// Default: sorted within braces
let paths = vec!;
let result = brace_paths?;
assert_eq!;
// Preserve input order
let config = BraceConfig ;
let result = brace_paths?;
assert_eq!;
Depth Limiting
Limit brace nesting to prevent performance issues:
let config = BraceConfig ;
let paths = vec!;
let result = brace_paths?;
assert_eq!;
// With max_depth: 1
// Result: a/b/{c/1,c/2,d/3}
CLI Usage
# From arguments
# Output: foo/{bar,baz}.rs
# From stdin
|
# Output: foo/{bar,baz}.rs
# With options
# With syntax highlighting (requires highlight feature)
CLI Options
| Option | Description |
|---|---|
--pretty |
Pretty-print the output with indentation |
--highlight |
Highlight brace groups with colors (requires highlight feature) |
--sort |
Sort items within braces alphabetically |
--stem-split |
Enable stem-level character splitting |
--no-segment-split |
Disable segment splitting (no empty components) |
--disallow-empty |
Output separate paths instead of empty braces |
--no-dedup |
Don't remove duplicate paths |
--reprocess |
Expand and reprocess existing braces |
--allow-mixed-sep |
Normalize mixed separators |
--preserve-order |
Maintain exact input order within braces |
--separator SEP |
Set path separator (default: /) |
--max-depth N |
Maximum brace nesting depth (default: 5) |
--max-brace-size N |
Maximum items per brace group |
-0, --null |
Read NUL-separated input (like xargs -0) |
-h, --help |
Print help message |
Configuration
BraceConfig options:
| Option | Type | Default | Description |
|---|---|---|---|
path_separator |
String |
"/" |
Path separator to use |
max_depth |
usize |
5 |
Maximum brace nesting depth |
max_brace_size |
Option<usize> |
None |
Maximum items per brace group |
allow_stem_split |
bool |
false |
Factor out character-level prefixes |
allow_segment_split |
bool |
true |
Allow empty alternatives like {,/c} |
sort_items |
bool |
false |
Sort items alphabetically |
disallow_empty_braces |
bool |
false |
Output separate paths instead of empty alternatives |
preserve_order_within_braces |
bool |
false |
Maintain exact input order within braces |
allow_mixed_separators |
bool |
false |
Normalize different separators to path_separator |
deduplicate_inputs |
bool |
true |
Remove duplicate paths before processing |
reprocess_braces |
bool |
false |
Expand and reprocess existing braces syntax |
highlight |
bool |
false |
Highlight braces with colors (requires highlight feature) |
Installation
Add to your project:
The easiest way to install the CLI is via cargo binstall (which pulls pre-built binaries from the release).
To build it yourself:
# Basic CLI
# CLI with syntax highlighting
# CLI with all features
Features
The crate supports the following feature flags:
cli- Enables the command-line interfacehighlight- Enables syntax highlighting for brace outputcli-highlight- Convenience feature enabling bothcliandhighlightcli-full- Alias forcli-highlightwith all CLI features
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.