cmdGlobalSet quickly sets a single option
(ctx *ShellContext, args string)
| 848 | |
| 849 | // cmdGlobalSet quickly sets a single option |
| 850 | func cmdGlobalSet(ctx *ShellContext, args string) error { |
| 851 | // Parse "key value" |
| 852 | parts := strings.SplitN(strings.TrimSpace(args), " ", 2) |
| 853 | if len(parts) < 2 { |
| 854 | fmt.Println("Usage: global set <key> <value>") |
| 855 | fmt.Println("\nSupported options:") |
| 856 | |
| 857 | // Display all options with descriptions |
| 858 | for _, key := range sshconfig.GetGlobalOptionNames() { |
| 859 | desc, _, validValues := sshconfig.GetGlobalOptionHelp(key) |
| 860 | fmt.Printf(" %-30s - %s", key, desc) |
| 861 | if len(validValues) > 0 { |
| 862 | fmt.Printf(" (%s)", strings.Join(validValues, "/")) |
| 863 | } |
| 864 | fmt.Println() |
| 865 | } |
| 866 | |
| 867 | fmt.Println("\nExample:") |
| 868 | fmt.Println(" global set ServerAliveInterval 60") |
| 869 | fmt.Println("\nTip: Use 'global edit' for interactive editing with help") |
| 870 | return nil |
| 871 | } |
| 872 | |
| 873 | key := strings.TrimSpace(parts[0]) |
| 874 | value := strings.TrimSpace(parts[1]) |
| 875 | |
| 876 | if err := sshconfig.SetGlobalOption(key, value); err != nil { |
| 877 | return fmt.Errorf("failed to set option: %w", err) |
| 878 | } |
| 879 | |
| 880 | fmt.Printf("\n✓ Set %s = %s\n", key, value) |
| 881 | fmt.Println("✓ Backup created") |
| 882 | return nil |
| 883 | } |
| 884 | |
| 885 | // cmdGlobalUnset removes a single option |
| 886 | func cmdGlobalUnset(ctx *ShellContext, args string) error { |
no test coverage detected