mirror of
https://github.com/on4kjm/FLEcli.git
synced 2025-01-31 06:51:02 +01:00
Add parsing of custom QSL Message
This commit is contained in:
parent
d4a9ff89b1
commit
1c702a3722
3 changed files with 17 additions and 1 deletions
|
@ -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", }},
|
||||
|
|
3
todo.md
3
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
|
||||
|
|
Loading…
Reference in a new issue