Add a new field to the config for enabling control-r search and add undocumented commands to toggle this field from the CLI

This commit is contained in:
David Dworken 2022-10-16 09:29:14 -07:00
parent 37f351bb8a
commit f337d7affd
2 changed files with 28 additions and 0 deletions

View File

@ -154,6 +154,8 @@ type ClientConfig struct {
MissedUploadTimestamp int64 `json:"missed_upload_timestamp"`
// Used for avoiding double imports of .bash_history
HaveCompletedInitialImport bool `json:"have_completed_initial_import"`
// Whether control-r bindings are enabled
ControlRSearchEnabled bool `json:"enable_control_r_search"`
}
func GetConfig() (ClientConfig, error) {

View File

@ -111,6 +111,32 @@ func main() {
if err != nil {
log.Fatalf("Failed to update hishtory: %v", err)
}
case "config-get":
// TODO: tests for config-get and config-set
ctx := hctx.MakeContext()
config := hctx.GetConf(ctx)
key := os.Args[2]
switch key {
case "enable-control-r":
fmt.Printf("%v", config.ControlRSearchEnabled)
default:
log.Fatalf("Unrecognized config key: %s", key)
}
case "config-set":
ctx := hctx.MakeContext()
config := hctx.GetConf(ctx)
key := os.Args[2]
val := os.Args[3]
switch key {
case "enable-control-r":
if val != "true" && val != "false" {
log.Fatalf("Unexpected config value %s, must be one of: true, false", val)
}
config.ControlRSearchEnabled = (val == "true")
lib.CheckFatalError(hctx.SetConfig(config))
default:
log.Fatalf("Unrecognized config key: %s", key)
}
case "reupload":
// Purposefully undocumented since this command is generally not necessary to run
lib.CheckFatalError(lib.Reupload(hctx.MakeContext()))