MCPcopy Create free account
hub / github.com/jetkvm/kvm / rpcGetSerialCommandHistory

Function rpcGetSerialCommandHistory

jsonrpc.go:912–930  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

910const SerialCommandHistoryPath = "/userdata/serialCommandHistory.json"
911
912func 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
932func rpcSetSerialCommandHistory(commandHistory []string) error {
933 logger.Trace().Str("path", SerialCommandHistoryPath).Msg("Saving serial command history")

Callers

nothing calls this directly

Calls 3

DebugMethod · 0.80
WarnMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected