| 910 | const SerialCommandHistoryPath = "/userdata/serialCommandHistory.json" |
| 911 | |
| 912 | func rpcGetSerialCommandHistory() ([]string, error) { |
| 913 | items := []string{} |
| 914 | |
| 915 | file, err := os.Open(SerialCommandHistoryPath) |
| 916 | if err != nil { |
| 917 | logger.Debug().Msg("SerialCommandHistory file doesn't exist, using default") |
| 918 | return items, nil |
| 919 | } |
| 920 | defer file.Close() |
| 921 | |
| 922 | // load and merge the default config with the user config |
| 923 | var loadedItems []string |
| 924 | if err := json.NewDecoder(file).Decode(&loadedItems); err != nil { |
| 925 | logger.Warn().Err(err).Msg("SerialCommandHistory file JSON parsing failed") |
| 926 | return items, nil |
| 927 | } |
| 928 | |
| 929 | return loadedItems, nil |
| 930 | } |
| 931 | |
| 932 | func rpcSetSerialCommandHistory(commandHistory []string) error { |
| 933 | logger.Trace().Str("path", SerialCommandHistoryPath).Msg("Saving serial command history") |