pub fn write_output(content: &str, path: Option<&str>) -> Result<(), CliError>Expand description
Write content to a file or stdout.
Writes the provided content to either a specified file path or to stdout if no path is provided. This is the standard output mechanism used by all HEDL CLI commands.
§Arguments
content- The string content to writepath- Optional output file path. IfNone, writes to stdout
§Returns
Returns Ok(()) on success.
§Errors
Returns Err if:
- File creation or writing fails (when
pathisSome) - Writing to stdout fails (when
pathisNone)
§Examples
use hedl_cli::commands::write_output;
// Write to stdout
let hedl_content = "%VERSION: 1.0\n---\nteams:@Team[name]\n |t1,Team A\n |t2,Team B";
write_output(hedl_content, None)?;
// Write to file
write_output(hedl_content, Some("output.hedl"))?;§Panics
Does not panic under normal circumstances. All I/O errors are returned
as Err values.