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