Skip to main content

render_output_for_copy

Function render_output_for_copy 

Source
pub fn render_output_for_copy(
    output: &OutputResult,
    settings: &RenderSettings,
) -> String
Expand description

Renders an output result in plain copy-safe form.

This keeps the caller’s format preference where possible, but forces the effective render settings onto a plain-text path so copied output does not contain ANSI escapes or terminal-only chrome.

§Examples

use osp_cli::core::output::{ColorMode, OutputFormat};
use osp_cli::core::output_model::OutputResult;
use osp_cli::row;
use osp_cli::ui::{RenderSettings, render_output_for_copy};

let output = OutputResult::from_rows(vec![row! { "uid" => "alice" }]);
let settings = RenderSettings::builder()
    .with_format(OutputFormat::Json)
    .with_color(ColorMode::Always)
    .build();
let rendered = render_output_for_copy(&output, &settings);

assert!(rendered.contains("\"uid\": \"alice\""));
assert!(!rendered.contains('\u{1b}'));