MCPcopy
hub / github.com/ddworken/hishtory / handleUpgradedFeatures

Function handleUpgradedFeatures

client/cmd/install.go:217–244  ·  view source on GitHub ↗

Handles people running `hishtory update` from an old version of hishtory that doesn't support certain config options that we now default to true. This ensures that we can customize the behavior for upgrades while still respecting the option if someone has it explicitly set.

()

Source from the content-addressed store, hash-verified

215// that we can customize the behavior for upgrades while still respecting the option
216// if someone has it explicitly set.
217func handleUpgradedFeatures() error {
218 configContents, err := hctx.GetConfigContents()
219 if err != nil {
220 // No config, so this is a new install and thus there is nothing to do
221 return nil
222 }
223 config, err := hctx.GetConfig()
224 if err != nil {
225 return err
226 }
227 if !strings.Contains(string(configContents), "enable_control_r_search") {
228 // control-r search is not yet configured, so enable it
229 config.ControlRSearchEnabled = true
230 }
231 if !strings.Contains(string(configContents), "highlight_matches") {
232 // highlighting is not yet configured, so enable it
233 config.HighlightMatches = true
234 }
235 if !strings.Contains(string(configContents), "enable_presaving") {
236 // Presaving is not yet configured, so enable it
237 config.EnablePresaving = true
238 }
239 if !strings.Contains(string(configContents), "ai_completion") {
240 // AI completion is not yet configured, disable it for upgrades since this is a new feature
241 config.AiCompletion = false
242 }
243 return hctx.SetConfig(&config)
244}
245
246func installBinary(homedir string) (string, error) {
247 clientPath, err := exec.LookPath("hishtory")

Callers 1

installFunction · 0.85

Calls 3

GetConfigContentsFunction · 0.92
GetConfigFunction · 0.92
SetConfigFunction · 0.92

Tested by

no test coverage detected