diff --git a/cmd/parse_line.go b/cmd/parse_line.go index 4933f40..843742e 100644 --- a/cmd/parse_line.go +++ b/cmd/parse_line.go @@ -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 = ">" diff --git a/cmd/parse_line_test.go b/cmd/parse_line_test.go index 1b60bbd..060435c 100644 --- a/cmd/parse_line_test.go +++ b/cmd/parse_line_test.go @@ -27,6 +27,11 @@ func TestParseLine(t *testing.T) { args{ inputStr: "4 g3noh ", previousLine: LogLine{ Mode: "SSB", }}, LogLine{ Comment: "PSE QSL Direct", Call: "G3NOH", Time: "2"}, "", }, + { + "Parse for QSL", + args{ inputStr: "4 g3noh ", previousLine: LogLine{ Mode: "SSB", }}, + LogLine{ QSLmsg: "Custom QSL message", Call: "G3NOH", Time: "2"}, "", + }, { "Wrong mode", args{ inputStr: "cww", previousLine: LogLine{ Mode: "SSB", }}, diff --git a/todo.md b/todo.md index 8edf94c..cc4f978 100644 --- a/todo.md +++ b/todo.md @@ -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