From c84b99af62ac8b997fed6526f68a607805ce394e Mon Sep 17 00:00:00 2001 From: Jean-Marc MEESSEN Date: Tue, 9 Jun 2020 12:48:38 +0200 Subject: [PATCH] Add Nickname header field parsing --- cmd/load.go | 19 ++++++++++++++++--- test/data/fullFeatureHeader.txt | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 test/data/fullFeatureHeader.txt diff --git a/cmd/load.go b/cmd/load.go index 1b3bbed..7935f2a 100644 --- a/cmd/load.go +++ b/cmd/load.go @@ -83,14 +83,15 @@ func loadFile() { regexpHeaderMyWwff, _ := regexp.Compile("(?i)^mywwff ") regexpHeaderMySota, _ := regexp.Compile("(?i)^mysota ") regexpHeaderQslMsg, _ := regexp.Compile("(?i)^qslmsg ") - // regexpHeaderNickname, _ := regexp.Compile("(?i)^nickname ") + regexpHeaderNickname, _ := regexp.Compile("(?i)^nickname ") // regexpHeaderDate, _ := regexp.Compile("(?i)^date ") headerMyCall := "" headerOperator := "" headerMyWWFF := "" headerMySOTA := "" - //headerQslMsg := "" + headerQslMsg := "" + headerNickname := "" lineCount := 0 var isInMultiLine = false @@ -200,7 +201,19 @@ func loadFile() { if(regexpHeaderQslMsg.MatchString(eachline)) { myQslMsgList := regexpHeaderQslMsg.Split(eachline,-1) if(len(myQslMsgList[1]) > 0) { - cleanedInput = append(cleanedInput, fmt.Sprintf("QSL Message: %s", myQslMsgList[1])) + headerQslMsg = myQslMsgList[1] + cleanedInput = append(cleanedInput, fmt.Sprintf("QSL Message: %s", headerQslMsg)) + } + //If there is no data after the marker, we just skip the data. + continue + } + + //QSL Message + if(regexpHeaderNickname.MatchString(eachline)) { + myNicknameList := regexpHeaderNickname.Split(eachline,-1) + if(len(myNicknameList[1]) > 0) { + headerNickname = myNicknameList[1] + cleanedInput = append(cleanedInput, fmt.Sprintf("eQSL Nickmane: %s", headerNickname)) } //If there is no data after the marker, we just skip the data. continue diff --git a/test/data/fullFeatureHeader.txt b/test/data/fullFeatureHeader.txt new file mode 100644 index 0000000..1c1b815 --- /dev/null +++ b/test/data/fullFeatureHeader.txt @@ -0,0 +1,16 @@ +# Header +mycall on4kjm/p +operator on4kjm +nickname Portable +myWwff onff-0258 +mySota on/on-001 +QslMsg This is a QSL message +date 2020-05-23 + +# Log +40m cw +7.018 0950 ik5zve/5 9 5 +7.025 0958 iz2bzt 9 5 +7.037 1012 on6zq 9 449 +1020 dk5zx 9 7 +30m cw