Show details for a server profile.
(&self, show: &ServerShow)
| 339 | |
| 340 | /// Show details for a server profile. |
| 341 | fn show_server(&self, show: &ServerShow) -> CliResult<()> { |
| 342 | let config = GlobalConfig::load() |
| 343 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load config: {}", e)))?; |
| 344 | |
| 345 | let (name, profile) = if let Some(ref n) = show.name { |
| 346 | // Explicit name |
| 347 | let p = config |
| 348 | .servers |
| 349 | .get(n) |
| 350 | .ok_or_else(|| CliError::InvalidArgument { |
| 351 | message: format!("Server profile '{}' not found.", n), |
| 352 | })?; |
| 353 | (n.as_str(), p) |
| 354 | } else if let Some(ref active) = config.default_server { |
| 355 | // Active named profile |
| 356 | let p = config |
| 357 | .servers |
| 358 | .get(active) |
| 359 | .ok_or_else(|| CliError::InvalidArgument { |
| 360 | message: format!("Default server profile '{}' not found in config.", active), |
| 361 | })?; |
| 362 | (active.as_str(), p) |
| 363 | } else { |
| 364 | // Legacy block — show it directly |
| 365 | println!("Active server: (legacy [server] block)"); |
| 366 | println!( |
| 367 | " URL: {}", |
| 368 | config.server.url.as_deref().unwrap_or("(not configured)") |
| 369 | ); |
| 370 | println!( |
| 371 | " Org: {}", |
| 372 | config |
| 373 | .server |
| 374 | .default_org |
| 375 | .as_deref() |
| 376 | .unwrap_or("(not configured)") |
| 377 | ); |
| 378 | if let Some(ref identity) = config.server.identity { |
| 379 | println!(" Identity: {}", identity); |
| 380 | } else { |
| 381 | println!(" Identity: (global default)"); |
| 382 | } |
| 383 | if !config.server.default_workspaces.is_empty() { |
| 384 | println!(" Workspaces:"); |
| 385 | for (org, ws) in &config.server.default_workspaces { |
| 386 | println!(" {} → {}", org, ws); |
| 387 | } |
| 388 | } |
| 389 | return Ok(()); |
| 390 | }; |
| 391 | |
| 392 | let is_active = config.default_server.as_deref() == Some(name); |
| 393 | println!( |
| 394 | "Server profile: {}{}", |
| 395 | name, |
| 396 | if is_active { " (active)" } else { "" } |
| 397 | ); |
| 398 | println!( |