cmdShow displays detailed host configuration
(ctx *ShellContext, args string)
| 418 | |
| 419 | // cmdShow displays detailed host configuration |
| 420 | func cmdShow(ctx *ShellContext, args string) error { |
| 421 | hostName := strings.TrimSpace(args) |
| 422 | if hostName == "" { |
| 423 | fmt.Println("Usage: show <host>") |
| 424 | return nil |
| 425 | } |
| 426 | |
| 427 | // Load configuration |
| 428 | cfg, err := sshconfig.LoadHostConfig(hostName) |
| 429 | if err != nil { |
| 430 | return fmt.Errorf("host not found: %w", err) |
| 431 | } |
| 432 | |
| 433 | // Display configuration |
| 434 | fmt.Printf("\n=== Host: %s ===\n", cfg.Name) |
| 435 | fmt.Printf("Hostname: %s\n", cfg.Hostname) |
| 436 | |
| 437 | if cfg.User != "" { |
| 438 | fmt.Printf("User: %s\n", cfg.User) |
| 439 | } |
| 440 | if cfg.Port != "" { |
| 441 | fmt.Printf("Port: %s\n", cfg.Port) |
| 442 | } else { |
| 443 | fmt.Printf("Port: 22 (default)\n") |
| 444 | } |
| 445 | |
| 446 | if cfg.IdentityAgent != "" { |
| 447 | fmt.Printf("IdentityAgent: %s\n", cfg.IdentityAgent) |
| 448 | } |
| 449 | for _, idFile := range cfg.IdentityFile { |
| 450 | fmt.Printf("IdentityFile: %s\n", idFile) |
| 451 | } |
| 452 | |
| 453 | if cfg.ProxyJump != "" { |
| 454 | fmt.Printf("ProxyJump: %s\n", cfg.ProxyJump) |
| 455 | } |
| 456 | if cfg.ProxyCommand != "" { |
| 457 | fmt.Printf("ProxyCommand: %s\n", cfg.ProxyCommand) |
| 458 | } |
| 459 | |
| 460 | if cfg.ForwardAgent != "" { |
| 461 | fmt.Printf("ForwardAgent: %s\n", cfg.ForwardAgent) |
| 462 | } |
| 463 | if cfg.ServerAliveInterval != "" { |
| 464 | fmt.Printf("ServerAliveInterval: %s\n", cfg.ServerAliveInterval) |
| 465 | } |
| 466 | |
| 467 | fmt.Println() |
| 468 | return nil |
| 469 | } |
| 470 | |
| 471 | // cmdInfo displays detailed host configuration by ID, alias, hostname, or IP |
| 472 | func cmdInfo(ctx *ShellContext, args string) error { |
no test coverage detected