Added callsign to line parsing

pull/2/head
Jean-Marc MEESSEN 5 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)
}
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 + " "

@ -25,12 +25,12 @@ func TestParseLine(t *testing.T) {
{
"Parse for comment",
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",
args{ inputStr: "4 g3noh <Custom QSL message>", 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",

Loading…
Cancel
Save