diff --git a/cmd/parse_line.go b/cmd/parse_line.go index b7f18f5..665eec8 100644 --- a/cmd/parse_line.go +++ b/cmd/parse_line.go @@ -56,10 +56,9 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg fmt.Println("Cleaned input string: ", inputStr) } - comment,inputStr = getBraketedData(inputStr, QSL) - if comment != "" { - logLine.QSLmsg = comment - inputStr = strings.Replace(inputStr, "[" + comment + "]", "",1) + QSLmsg,inputStr := getBraketedData(inputStr, QSL) + if QSLmsg != "" { + logLine.QSLmsg = QSLmsg fmt.Println("Cleaned input string: ", inputStr) } @@ -80,6 +79,14 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg continue } + // Is it a call sign ? + if validCallRegexp.MatchString(strings.ToUpper(element)) { + callErrorMsg := "" + logLine.Call, callErrorMsg = ValidateCall(element) + errorMsg = errorMsg + callErrorMsg + continue + } + //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 060435c..ff96835 100644 --- a/cmd/parse_line_test.go +++ b/cmd/parse_line_test.go @@ -25,12 +25,12 @@ func TestParseLine(t *testing.T) { { "Parse for comment", args{ inputStr: "4 g3noh ", previousLine: LogLine{ Mode: "SSB", }}, - LogLine{ Comment: "PSE QSL Direct", Call: "G3NOH", Time: "2"}, "", + LogLine{ Comment: "PSE QSL Direct", Call: "G3NOH", Mode: "SSB",}, "Unable to parse 4 ", }, { "Parse for QSL", - args{ inputStr: "4 g3noh ", previousLine: LogLine{ Mode: "SSB", }}, - LogLine{ QSLmsg: "Custom QSL message", Call: "G3NOH", Time: "2"}, "", + args{ inputStr: "g3noh [Custom QSL message]", previousLine: LogLine{ Mode: "SSB", }}, + LogLine{ QSLmsg: "Custom QSL message", Call: "G3NOH", Mode: "SSB",}, "", }, { "Wrong mode",