MCPcopy Create free account
hub / github.com/Mister-leo/fssh / cmdInfo

Function cmdInfo

cmd/fssh/shell_commands.go:472–533  ·  view source on GitHub ↗

cmdInfo displays detailed host configuration by ID, alias, hostname, or IP

(ctx *ShellContext, args string)

Source from the content-addressed store, hash-verified

470
471// cmdInfo displays detailed host configuration by ID, alias, hostname, or IP
472func cmdInfo(ctx *ShellContext, args string) error {
473 query := strings.TrimSpace(args)
474 if query == "" {
475 fmt.Println("Usage: info <id|alias|hostname|ip>")
476 return nil
477 }
478
479 // Resolve query to host alias
480 hostName := resolveHostQuery(ctx, query)
481 if hostName == "" {
482 return fmt.Errorf("host not found: %s", query)
483 }
484
485 // Load configuration
486 cfg, err := sshconfig.LoadHostConfig(hostName)
487 if err != nil {
488 return fmt.Errorf("failed to load host config: %w", err)
489 }
490
491 // Display configuration
492 fmt.Printf("\n=== Host: %s ===\n", cfg.Name)
493 fmt.Printf("Hostname: %s\n", cfg.Hostname)
494
495 // Resolve IP if possible
496 ip := resolveIPName(cfg.Hostname)
497 if ip != "" {
498 fmt.Printf("IP: %s\n", ip)
499 }
500
501 if cfg.User != "" {
502 fmt.Printf("User: %s\n", cfg.User)
503 }
504 if cfg.Port != "" {
505 fmt.Printf("Port: %s\n", cfg.Port)
506 } else {
507 fmt.Printf("Port: 22 (default)\n")
508 }
509
510 if cfg.IdentityAgent != "" {
511 fmt.Printf("IdentityAgent: %s\n", cfg.IdentityAgent)
512 }
513 for _, idFile := range cfg.IdentityFile {
514 fmt.Printf("IdentityFile: %s\n", idFile)
515 }
516
517 if cfg.ProxyJump != "" {
518 fmt.Printf("ProxyJump: %s\n", cfg.ProxyJump)
519 }
520 if cfg.ProxyCommand != "" {
521 fmt.Printf("ProxyCommand: %s\n", cfg.ProxyCommand)
522 }
523
524 if cfg.ForwardAgent != "" {
525 fmt.Printf("ForwardAgent: %s\n", cfg.ForwardAgent)
526 }
527 if cfg.ServerAliveInterval != "" {
528 fmt.Printf("ServerAliveInterval: %s\n", cfg.ServerAliveInterval)
529 }

Callers 1

runShellFunction · 0.85

Calls 3

LoadHostConfigFunction · 0.92
resolveHostQueryFunction · 0.85
resolveIPNameFunction · 0.85

Tested by

no test coverage detected