pub fn batch_format(
files: Vec<String>,
output_dir: Option<String>,
check: bool,
ditto: bool,
with_counts: bool,
parallel: bool,
verbose: bool,
) -> Result<(), String>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
files- List of file paths to formatoutput_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 listsparallel- 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 files = vec!["file1.hedl".to_string(), "file2.hedl".to_string()];
batch_format(files, Some("formatted/".to_string()), false, true, false, true, false)?;
// Check if files are canonical
let files = vec!["test1.hedl".to_string(), "test2.hedl".to_string()];
batch_format(files, None, true, true, false, true, false)?;
// Format with count hints
let files = vec!["data.hedl".to_string()];
batch_format(files, Some("output/".to_string()), false, true, true, false, true)?;§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.