pub fn batch_format(params: BatchFormatParams) -> 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, BatchFormatParams};
// Format files to output directory
batch_format(BatchFormatParams {
patterns: vec!["*.hedl".to_string()],
output_dir: Some("formatted/".to_string()),
check: false,
ditto: true,
with_counts: false,
recursive: false,
max_depth: 10,
parallel: true,
verbose: false,
max_files_override: None,
})?;§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.