pub fn batch_format(
patterns: Vec<String>,
output_dir: Option<String>,
check: bool,
ditto: bool,
with_counts: bool,
recursive: bool,
max_depth: usize,
parallel: bool,
verbose: bool,
) -> Result<(), CliError>Expand description
Batch format multiple HEDL files to canonical form.
Formats multiple HEDL files to canonical form, with options for check-only mode, ditto optimization, and count hints. Supports parallel processing for improved performance on large file sets.
§Arguments
patterns- List of file patterns (glob patterns or explicit paths)output_dir- Optional output directory for formatted files. IfNone, files are processed in-placecheck- Iftrue, only checks if files are canonical without reformattingditto- Iftrue, uses ditto optimization (repeated values as")with_counts- Iftrue, automatically adds count hints to all matrix listsrecursive- Enable recursive directory traversalmax_depth- Maximum recursion depthparallel- Iftrue, processes files in parallel (automatically enabled for 4+ files)verbose- Iftrue, shows detailed progress information
§Returns
Returns Ok(()) if all files are successfully formatted, Err with a summary if any fail.
§Errors
Returns Err if:
- Any file cannot be read
- Any file contains syntax errors
- Canonicalization fails for any file
- In check mode, if any file is not already canonical
- Output directory cannot be created
- Formatted files cannot be written
§Examples
use hedl_cli::commands::batch_format;
// Format files to output directory
let patterns = vec!["*.hedl".to_string()];
batch_format(patterns, Some("formatted/".to_string()), false, true, false, false, 10, true, false)?;
// Check if files are canonical
let patterns = vec!["**/*.hedl".to_string()];
batch_format(patterns, None, true, true, false, true, 10, true, false)?;§Output
Displays progress information and a summary:
- Success/failure for each file (✓ or ✗)
- Detailed error messages for failures
- Final count of failures
§Performance
Automatically uses parallel processing when beneficial (4+ files by default).
Can be forced with the parallel flag for smaller file sets.