MCPcopy Create free account
hub / github.com/BigBoot/AutoKuma / print_value

Function print_value

kuma-cli/src/utils.rs:82–106  ·  view source on GitHub ↗
(value: &T, cli: &Cli)

Source from the content-addressed store, hash-verified

80}
81
82pub(crate) fn print_value<T>(value: &T, cli: &Cli)
83where
84 T: Serialize,
85{
86 let str = match (&cli.output_format, &cli.output_pretty) {
87 (OutputFormat::Json, true) => Highlighter::new()
88 .highlight_to_string(
89 inkjet::Language::Json,
90 &ColorPrinter::new(),
91 serde_json::to_string_pretty(value).unwrap(),
92 )
93 .unwrap(),
94 (OutputFormat::Json, false) => serde_json::to_string(value).unwrap(),
95 (OutputFormat::Yaml, true) => Highlighter::new()
96 .highlight_to_string(
97 inkjet::Language::Yaml,
98 &ColorPrinter::new(),
99 serde_yaml::to_string(value).unwrap(),
100 )
101 .unwrap(),
102 (OutputFormat::Yaml, false) => serde_yaml::to_string(value).unwrap(),
103 };
104
105 print!("{}", str);
106}
107
108#[derive(Deserialize, Serialize)]
109#[serde(untagged)]

Callers 3

print_resultMethod · 0.85
unwrap_or_dieMethod · 0.85
handleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected