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
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 |
Installation
Or install the CLI:
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.