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

Function format_labels

crates/openshell-tui/src/app.rs:679–690  ·  view source on GitHub ↗

Format object labels as a comma-separated key=value string. Labels are sorted by key for deterministic output. Returns an empty string if the map is empty. Values are sanitized to prevent terminal escape sequences.

(labels: &HashMap<String, String>)

Source from the content-addressed store, hash-verified

677/// Labels are sorted by key for deterministic output. Returns an empty string
678/// if the map is empty. Values are sanitized to prevent terminal escape sequences.
679pub fn format_labels(labels: &HashMap<String, String>) -> String {
680 if labels.is_empty() {
681 return String::new();
682 }
683 let mut sorted: Vec<_> = labels.iter().collect();
684 sorted.sort_by_key(|(k, _)| *k);
685 sorted
686 .iter()
687 .map(|(k, v)| format!("{}={}", sanitize_for_display(k), sanitize_for_display(v)))
688 .collect::<Vec<_>>()
689 .join(",")
690}
691
692pub fn provider_name(provider: &openshell_core::proto::Provider) -> &str {
693 provider

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected