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

Function gateway_select

crates/openshell-cli/src/run.rs:615–632  ·  view source on GitHub ↗
(name: Option<&str>, gateway_flag: &Option<String>)

Source from the content-addressed store, hash-verified

613}
614
615pub fn gateway_select(name: Option<&str>, gateway_flag: &Option<String>) -> Result<()> {
616 let interactive = std::io::stdin().is_terminal() && std::io::stdout().is_terminal();
617 gateway_select_with(name, gateway_flag, interactive, |gateways, default| {
618 let prompt = format!(
619 "Select a gateway\n{}",
620 format_gateway_select_header(gateways)
621 );
622 let items = format_gateway_select_items(gateways);
623 Select::with_theme(&ColorfulTheme::default())
624 .with_prompt(prompt)
625 .items(&items)
626 .default(default)
627 .report(false)
628 .interact_opt()
629 .into_diagnostic()
630 .map(|selection| selection.map(|index| gateways[index].name.clone()))
631 })
632}
633
634fn format_gateway_select_header(gateways: &[GatewayMetadata]) -> String {
635 let (name_width, endpoint_width, type_width) = gateway_select_column_widths(gateways);

Callers 1

mainFunction · 0.85

Calls 3

gateway_select_withFunction · 0.85
defaultMethod · 0.45

Tested by

no test coverage detected