Added callsign to line parsing

pull/2/head
Jean-Marc MEESSEN 4 years ago
parent c498c72fb1
commit fb41ebd2ef

@ -56,10 +56,9 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
fmt.Println("Cleaned input string: ", inputStr) fmt.Println("Cleaned input string: ", inputStr)
} }
comment,inputStr = getBraketedData(inputStr, QSL) QSLmsg,inputStr := getBraketedData(inputStr, QSL)
if comment != "" { if QSLmsg != "" {
logLine.QSLmsg = comment logLine.QSLmsg = QSLmsg
inputStr = strings.Replace(inputStr, "[" + comment + "]", "",1)
fmt.Println("Cleaned input string: ", inputStr) fmt.Println("Cleaned input string: ", inputStr)
} }
@ -80,6 +79,14 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
continue 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 //If we come here, we could not make sense of what we found
errorMsg = errorMsg + "Unable to parse " + element + " " errorMsg = errorMsg + "Unable to parse " + element + " "

@ -25,12 +25,12 @@ func TestParseLine(t *testing.T) {
{ {
"Parse for comment", "Parse for comment",
args{ inputStr: "4 g3noh <PSE QSL Direct>", previousLine: LogLine{ Mode: "SSB", }}, args{ inputStr: "4 g3noh <PSE QSL Direct>", 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", "Parse for QSL",
args{ inputStr: "4 g3noh <Custom QSL message>", previousLine: LogLine{ Mode: "SSB", }}, args{ inputStr: "g3noh [Custom QSL message]", previousLine: LogLine{ Mode: "SSB", }},
LogLine{ QSLmsg: "Custom QSL message", Call: "G3NOH", Time: "2"}, "", LogLine{ QSLmsg: "Custom QSL message", Call: "G3NOH", Mode: "SSB",}, "",
}, },
{ {
"Wrong mode", "Wrong mode",

Loading…
Cancel
Save