MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / print_yaml_line

Function print_yaml_line

crates/openshell-cli/src/run.rs:3282–3320  ·  view source on GitHub ↗

Print a single YAML line with dimmed keys and regular values.

(line: &str)

Source from the content-addressed store, hash-verified

3280
3281/// Print a single YAML line with dimmed keys and regular values.
3282fn print_yaml_line(line: &str) {
3283 // Find leading whitespace
3284 let trimmed = line.trim_start();
3285 let indent = &line[..line.len() - trimmed.len()];
3286
3287 // Handle list items
3288 if let Some(rest) = trimmed.strip_prefix("- ") {
3289 print!("{indent}");
3290 print!("{}", "- ".dimmed());
3291 print!("{rest}");
3292 println!();
3293 return;
3294 }
3295
3296 // Handle key: value pairs
3297 if let Some(colon_pos) = trimmed.find(':') {
3298 let key = &trimmed[..colon_pos];
3299 let after_colon = &trimmed[colon_pos + 1..];
3300
3301 print!("{indent}");
3302 print!("{}", key.dimmed());
3303 print!("{}", ":".dimmed());
3304
3305 if after_colon.is_empty() {
3306 // Key with nested content (no value on this line)
3307 } else if let Some(value) = after_colon.strip_prefix(' ') {
3308 // Key: value
3309 print!(" {value}");
3310 } else {
3311 // Shouldn't happen in valid YAML, but handle it
3312 print!("{after_colon}");
3313 }
3314 println!();
3315 return;
3316 }
3317
3318 // Plain line (shouldn't happen often in YAML)
3319 println!("{line}");
3320}
3321
3322/// Print sandbox policy as YAML with dimmed keys.
3323fn print_sandbox_policy(policy: &SandboxPolicy) {

Callers 1

print_sandbox_policyFunction · 0.85

Calls 2

lenMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected