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

Function SetGlobalOption

internal/sshconfig/global.go:92–117  ·  view source on GitHub ↗

SetGlobalOption sets a single global configuration option Creates Host * block if it doesn't exist

(key, value string)

Source from the content-addressed store, hash-verified

90// SetGlobalOption sets a single global configuration option
91// Creates Host * block if it doesn't exist
92func SetGlobalOption(key, value string) error {
93 // Normalize key (case-insensitive)
94 key = normalizeConfigKey(key)
95
96 // Validate option name
97 if !IsValidGlobalOption(key) {
98 return fmt.Errorf("unsupported global option: %s", key)
99 }
100
101 // Load existing config or create new one
102 cfg, found, err := LoadGlobalConfig()
103 if err != nil {
104 return err
105 }
106 if !found {
107 cfg = NewGlobalConfig()
108 }
109
110 // Set the option value
111 if err := setConfigField(cfg, key, value); err != nil {
112 return err
113 }
114
115 // Write back
116 return WriteGlobalConfig(cfg)
117}
118
119// UnsetGlobalOption removes a global configuration option
120func UnsetGlobalOption(key string) error {

Callers 1

cmdGlobalSetFunction · 0.92

Calls 6

normalizeConfigKeyFunction · 0.85
IsValidGlobalOptionFunction · 0.85
LoadGlobalConfigFunction · 0.85
NewGlobalConfigFunction · 0.85
setConfigFieldFunction · 0.85
WriteGlobalConfigFunction · 0.85

Tested by

no test coverage detected