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

Function resolve_sandbox_name

crates/openshell-cli/src/main.rs:211–223  ·  view source on GitHub ↗

Resolve a sandbox name, falling back to the last-used sandbox for the gateway. When `name` is `None`, looks up the last sandbox recorded for the active gateway. Prints a hint when falling back so the user knows which sandbox was chosen.

(name: Option<String>, gateway: &str)

Source from the content-addressed store, hash-verified

209/// gateway. Prints a hint when falling back so the user knows which sandbox
210/// was chosen.
211fn resolve_sandbox_name(name: Option<String>, gateway: &str) -> Result<String> {
212 if let Some(n) = name {
213 return Ok(n);
214 }
215 let last = load_last_sandbox(gateway).ok_or_else(|| {
216 miette::miette!(
217 "No sandbox name provided and no last-used sandbox.\n\
218 Specify a sandbox name or connect to one first: openshell sandbox connect <name>"
219 )
220 })?;
221 eprintln!("{} Using sandbox '{}' (last used)", "→".bold(), last.bold());
222 Ok(last)
223}
224
225// Custom root help stays hand-authored so commands can be grouped into product
226// areas without relying on clap's default subcommand listing. User-facing

Calls 1

load_last_sandboxFunction · 0.85