| 930 | } |
| 931 | |
| 932 | func rpcSetSerialCommandHistory(commandHistory []string) error { |
| 933 | logger.Trace().Str("path", SerialCommandHistoryPath).Msg("Saving serial command history") |
| 934 | |
| 935 | file, err := os.Create(SerialCommandHistoryPath) |
| 936 | if err != nil { |
| 937 | return fmt.Errorf("failed to create SerialCommandHistory file: %w", err) |
| 938 | } |
| 939 | defer file.Close() |
| 940 | |
| 941 | encoder := json.NewEncoder(file) |
| 942 | encoder.SetIndent("", " ") |
| 943 | if err := encoder.Encode(commandHistory); err != nil { |
| 944 | return fmt.Errorf("failed to encode SerialCommandHistory: %w", err) |
| 945 | } |
| 946 | |
| 947 | return nil |
| 948 | } |
| 949 | |
| 950 | func rpcDeleteSerialCommandHistory() error { |
| 951 | logger.Trace().Str("path", SerialCommandHistoryPath).Msg("Deleting serial command history") |