diff --git a/cmd/parse_line.go b/cmd/parse_line.go index b031b97..91320a4 100644 --- a/cmd/parse_line.go +++ b/cmd/parse_line.go @@ -55,9 +55,10 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg //TODO: input null protection? //Flag telling that we are processing data to the right of the callsign - //isRightOfCall := false + isRightOfCall := false //TODO: Make something more intelligent + //TODO: What happens if we have partial lines previousLine.Call = "" previousLine.RSTsent = "" previousLine.RSTrcvd = "" @@ -116,26 +117,29 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg callErrorMsg := "" logLine.Call, callErrorMsg = ValidateCall(element) errorMsg = errorMsg + callErrorMsg - //isRightOfCall = true + isRightOfCall = true continue } // Is it a "full" time ? - if regexpIsFullTime.MatchString(element) { - logLine.Time = element - continue - } - - // Is it a partial time ? - if regexpIsTimePart.MatchString(element) { - if logLine.Time == "" { + if isRightOfCall == false { + if regexpIsFullTime.MatchString(element) { logLine.Time = element - } else { - goodPart := logLine.Time[:len(logLine.Time)-len(element)] - logLine.Time = goodPart + element + continue + } + + // Is it a partial time ? + if regexpIsTimePart.MatchString(element) { + if logLine.Time == "" { + logLine.Time = element + } else { + goodPart := logLine.Time[:len(logLine.Time)-len(element)] + logLine.Time = goodPart + element + } + continue } - continue } + // Is it the OM's name (starting with "@") if regexpIsOMname.MatchString(element) { @@ -150,6 +154,12 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg continue } + if isRightOfCall { + //This is probably a RST + //TODO: is it a number (or a data report) + //TODO: it is sent or rcvd + } + //If we come here, we could not make sense of what we found errorMsg = errorMsg + "Unable to parse " + element + " " diff --git a/cmd/parse_line_test.go b/cmd/parse_line_test.go index d4967b4..cf9d041 100644 --- a/cmd/parse_line_test.go +++ b/cmd/parse_line_test.go @@ -67,6 +67,11 @@ func TestParseLine(t *testing.T) { args{ inputStr: "#grid", previousLine: LogLine{ Mode: "SSB", }}, LogLine{ GridLoc: "grid", Mode: "SSB",}, "", }, + { + "parse partial RST", + args{ inputStr: "1230 on4kjm 5", previousLine: LogLine{ Mode: "CW", }}, + LogLine{ Call: "ON4KJM", Time: "1230", RSTsent: "559", Mode: "CW",}, "", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/todo.md b/todo.md index abb7834..02113f4 100644 --- a/todo.md +++ b/todo.md @@ -6,12 +6,15 @@ ## Test framework * [x] enable TDD -* [ ] automate build and test -* [ ] type of target (cross compile) ? +* [x] automate build and test +* [ ] Improve build processing (cross compile, directory) +* [ ] Perform the test of the complete app ## Input processing * [ ] infer rst +* [ ] DATE keyword is now optional +* [ ] New MYGRID keyword * [ ] Create the logic to take over from the previous line * [ ] Support different date delimiter * [ ] Support extrapolated date