SetGlobalOption sets a single global configuration option Creates Host * block if it doesn't exist
(key, value string)
| 90 | // SetGlobalOption sets a single global configuration option |
| 91 | // Creates Host * block if it doesn't exist |
| 92 | func 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 |
| 120 | func UnsetGlobalOption(key string) error { |
no test coverage detected