Add parsing of custom QSL Message

pull/2/head
Jean-Marc Meessen 5 years ago
parent d4a9ff89b1
commit 1c702a3722

@ -49,6 +49,7 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
logLine = previousLine
//TODO: what happens when we have <> or when there are multiple comments
//TODO: Refactor this! it is ugly
comment := getBraketedData(inputStr, "COMMENT")
if comment != "" {
logLine.Comment = comment
@ -56,6 +57,14 @@ func ParseLine(inputStr string, previousLine LogLine) (logLine LogLine, errorMsg
fmt.Println("Cleaned input string: ", inputStr)
}
comment = getBraketedData(inputStr, "QSL")
if comment != "" {
logLine.QSLmsg = comment
inputStr = strings.Replace(inputStr, "[" + comment + "]", "",1)
fmt.Println("Cleaned input string: ", inputStr)
}
elements := strings.Fields(inputStr)
for _, element := range elements {
@ -110,6 +119,7 @@ func getBraketedData(value, braketType string) (text string) {
a := ""
b := ""
//TODO: refactor that as a switch statement to exclude non supported bracket types
if braketType == "COMMENT" {
a = "<"
b = ">"

@ -27,6 +27,11 @@ func TestParseLine(t *testing.T) {
args{ inputStr: "4 g3noh <PSE QSL Direct>", previousLine: LogLine{ Mode: "SSB", }},
LogLine{ Comment: "PSE QSL Direct", Call: "G3NOH", Time: "2"}, "",
},
{
"Parse for QSL",
args{ inputStr: "4 g3noh <Custom QSL message>", previousLine: LogLine{ Mode: "SSB", }},
LogLine{ QSLmsg: "Custom QSL message", Call: "G3NOH", Time: "2"}, "",
},
{
"Wrong mode",
args{ inputStr: "cww", previousLine: LogLine{ Mode: "SSB", }},

@ -14,4 +14,5 @@
* [x] Read the file into array
* [x] Parse every line
* [x] Load structured data
* [ ] Create structured data storage
* [X] Create structured data storage
* [ ] Create the logic to take over from the previous line

Loading…
Cancel
Save