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)
| 209 | /// gateway. Prints a hint when falling back so the user knows which sandbox |
| 210 | /// was chosen. |
| 211 | fn 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 |