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

Function cmdGlobalSet

cmd/fssh/shell_commands.go:850–883  ·  view source on GitHub ↗

cmdGlobalSet quickly sets a single option

(ctx *ShellContext, args string)

Source from the content-addressed store, hash-verified

848
849// cmdGlobalSet quickly sets a single option
850func 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
886func cmdGlobalUnset(ctx *ShellContext, args string) error {

Callers 1

cmdGlobalFunction · 0.85

Calls 3

GetGlobalOptionNamesFunction · 0.92
GetGlobalOptionHelpFunction · 0.92
SetGlobalOptionFunction · 0.92

Tested by

no test coverage detected