|
|
@ -1,4 +1,5 @@
|
|
|
|
package cmd
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Copyright © 2020 Jean-Marc Meessen, ON4KJM <on4kjm@gmail.com>
|
|
|
|
Copyright © 2020 Jean-Marc Meessen, ON4KJM <on4kjm@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
@ -16,9 +17,9 @@ limitations under the License.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"bufio"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"bufio"
|
|
|
|
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"regexp"
|
|
|
|
"regexp"
|
|
|
@ -86,7 +87,6 @@ func loadFile() {
|
|
|
|
regexpHeaderNickname, _ := regexp.Compile("(?i)^nickname ")
|
|
|
|
regexpHeaderNickname, _ := regexp.Compile("(?i)^nickname ")
|
|
|
|
regexpHeaderDate, _ := regexp.Compile("(?i)^date ")
|
|
|
|
regexpHeaderDate, _ := regexp.Compile("(?i)^date ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
headerMyCall := ""
|
|
|
|
headerMyCall := ""
|
|
|
|
headerOperator := ""
|
|
|
|
headerOperator := ""
|
|
|
|
headerMyWWFF := ""
|
|
|
|
headerMyWWFF := ""
|
|
|
@ -103,7 +103,6 @@ func loadFile() {
|
|
|
|
var previousLogLine LogLine
|
|
|
|
var previousLogLine LogLine
|
|
|
|
var fullLog []LogLine
|
|
|
|
var fullLog []LogLine
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Loop through all the stored lined
|
|
|
|
//Loop through all the stored lined
|
|
|
|
for _, eachline := range txtlines {
|
|
|
|
for _, eachline := range txtlines {
|
|
|
|
lineCount++
|
|
|
|
lineCount++
|
|
|
@ -113,25 +112,25 @@ func loadFile() {
|
|
|
|
// ****
|
|
|
|
// ****
|
|
|
|
|
|
|
|
|
|
|
|
//Skip the line if it starts with "#"
|
|
|
|
//Skip the line if it starts with "#"
|
|
|
|
if(regexpLineComment.MatchString(eachline)) {
|
|
|
|
if regexpLineComment.MatchString(eachline) {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Skip if line is empty or blank
|
|
|
|
//Skip if line is empty or blank
|
|
|
|
if((len(eachline) == 0) || (regexpOnlySpaces.MatchString(eachline))) {
|
|
|
|
if (len(eachline) == 0) || (regexpOnlySpaces.MatchString(eachline)) {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Process multi-line comments
|
|
|
|
// Process multi-line comments
|
|
|
|
if(regexpStartMultiLineComment.MatchString(eachline)) {
|
|
|
|
if regexpStartMultiLineComment.MatchString(eachline) {
|
|
|
|
//Single-line "multi-line" coment
|
|
|
|
//Single-line "multi-line" coment
|
|
|
|
if(regexpSingleMultiLineComment.MatchString(eachline)) {
|
|
|
|
if regexpSingleMultiLineComment.MatchString(eachline) {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isInMultiLine = true
|
|
|
|
isInMultiLine = true
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(isInMultiLine) {
|
|
|
|
if isInMultiLine {
|
|
|
|
if(regexpEndMultiLineComment.MatchString(eachline)) {
|
|
|
|
if regexpEndMultiLineComment.MatchString(eachline) {
|
|
|
|
isInMultiLine = false
|
|
|
|
isInMultiLine = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
continue
|
|
|
@ -142,13 +141,13 @@ func loadFile() {
|
|
|
|
// ****
|
|
|
|
// ****
|
|
|
|
|
|
|
|
|
|
|
|
//My Call
|
|
|
|
//My Call
|
|
|
|
if(regexpHeaderMyCall.MatchString(eachline)) {
|
|
|
|
if regexpHeaderMyCall.MatchString(eachline) {
|
|
|
|
errorMsg := ""
|
|
|
|
errorMsg := ""
|
|
|
|
myCallList := regexpHeaderMyCall.Split(eachline, -1)
|
|
|
|
myCallList := regexpHeaderMyCall.Split(eachline, -1)
|
|
|
|
if(len(myCallList[1]) > 0) {
|
|
|
|
if len(myCallList[1]) > 0 {
|
|
|
|
headerMyCall, errorMsg = ValidateCall(myCallList[1])
|
|
|
|
headerMyCall, errorMsg = ValidateCall(myCallList[1])
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("My call: %s", headerMyCall))
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("My call: %s", headerMyCall))
|
|
|
|
if(len(errorMsg) != 0) {
|
|
|
|
if len(errorMsg) != 0 {
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid myCall at line %d: %s (%s)", lineCount, myCallList[1], errorMsg))
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid myCall at line %d: %s (%s)", lineCount, myCallList[1], errorMsg))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -157,13 +156,13 @@ func loadFile() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Operator
|
|
|
|
//Operator
|
|
|
|
if(regexpHeaderOperator.MatchString(eachline)) {
|
|
|
|
if regexpHeaderOperator.MatchString(eachline) {
|
|
|
|
errorMsg := ""
|
|
|
|
errorMsg := ""
|
|
|
|
myOperatorList := regexpHeaderOperator.Split(eachline, -1)
|
|
|
|
myOperatorList := regexpHeaderOperator.Split(eachline, -1)
|
|
|
|
if(len(myOperatorList[1]) > 0) {
|
|
|
|
if len(myOperatorList[1]) > 0 {
|
|
|
|
headerOperator, errorMsg = ValidateCall(myOperatorList[1])
|
|
|
|
headerOperator, errorMsg = ValidateCall(myOperatorList[1])
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("Operator: %s", headerOperator))
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("Operator: %s", headerOperator))
|
|
|
|
if(len(errorMsg) != 0) {
|
|
|
|
if len(errorMsg) != 0 {
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid Operator at line %d: %s (%s)", lineCount, myOperatorList[1], errorMsg))
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid Operator at line %d: %s (%s)", lineCount, myOperatorList[1], errorMsg))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -172,13 +171,13 @@ func loadFile() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// My WWFF
|
|
|
|
// My WWFF
|
|
|
|
if(regexpHeaderMyWwff.MatchString(eachline)) {
|
|
|
|
if regexpHeaderMyWwff.MatchString(eachline) {
|
|
|
|
errorMsg := ""
|
|
|
|
errorMsg := ""
|
|
|
|
myWwffList := regexpHeaderMyWwff.Split(eachline, -1)
|
|
|
|
myWwffList := regexpHeaderMyWwff.Split(eachline, -1)
|
|
|
|
if(len(myWwffList[1]) > 0) {
|
|
|
|
if len(myWwffList[1]) > 0 {
|
|
|
|
headerMyWWFF, errorMsg = ValidateWwff(myWwffList[1])
|
|
|
|
headerMyWWFF, errorMsg = ValidateWwff(myWwffList[1])
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("My WWFF: %s", headerMyWWFF))
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("My WWFF: %s", headerMyWWFF))
|
|
|
|
if(len(errorMsg) != 0) {
|
|
|
|
if len(errorMsg) != 0 {
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid \"My WWFF\" at line %d: %s (%s)", lineCount, myWwffList[1], errorMsg))
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid \"My WWFF\" at line %d: %s (%s)", lineCount, myWwffList[1], errorMsg))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -187,13 +186,13 @@ func loadFile() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//My Sota
|
|
|
|
//My Sota
|
|
|
|
if(regexpHeaderMySota.MatchString(eachline)) {
|
|
|
|
if regexpHeaderMySota.MatchString(eachline) {
|
|
|
|
errorMsg := ""
|
|
|
|
errorMsg := ""
|
|
|
|
mySotaList := regexpHeaderMySota.Split(eachline, -1)
|
|
|
|
mySotaList := regexpHeaderMySota.Split(eachline, -1)
|
|
|
|
if(len(mySotaList[1]) > 0) {
|
|
|
|
if len(mySotaList[1]) > 0 {
|
|
|
|
headerMySOTA, errorMsg = ValidateSota(mySotaList[1])
|
|
|
|
headerMySOTA, errorMsg = ValidateSota(mySotaList[1])
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("My Sota: %s", headerMySOTA))
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("My Sota: %s", headerMySOTA))
|
|
|
|
if(len(errorMsg) != 0) {
|
|
|
|
if len(errorMsg) != 0 {
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid \"My SOTA\" at line %d: %s (%s)", lineCount, mySotaList[1], errorMsg))
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid \"My SOTA\" at line %d: %s (%s)", lineCount, mySotaList[1], errorMsg))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -202,9 +201,9 @@ func loadFile() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//QSL Message
|
|
|
|
//QSL Message
|
|
|
|
if(regexpHeaderQslMsg.MatchString(eachline)) {
|
|
|
|
if regexpHeaderQslMsg.MatchString(eachline) {
|
|
|
|
myQslMsgList := regexpHeaderQslMsg.Split(eachline, -1)
|
|
|
|
myQslMsgList := regexpHeaderQslMsg.Split(eachline, -1)
|
|
|
|
if(len(myQslMsgList[1]) > 0) {
|
|
|
|
if len(myQslMsgList[1]) > 0 {
|
|
|
|
headerQslMsg = myQslMsgList[1]
|
|
|
|
headerQslMsg = myQslMsgList[1]
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("QSL Message: %s", headerQslMsg))
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("QSL Message: %s", headerQslMsg))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -213,9 +212,9 @@ func loadFile() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Nickname
|
|
|
|
//Nickname
|
|
|
|
if(regexpHeaderNickname.MatchString(eachline)) {
|
|
|
|
if regexpHeaderNickname.MatchString(eachline) {
|
|
|
|
myNicknameList := regexpHeaderNickname.Split(eachline, -1)
|
|
|
|
myNicknameList := regexpHeaderNickname.Split(eachline, -1)
|
|
|
|
if(len(myNicknameList[1]) > 0) {
|
|
|
|
if len(myNicknameList[1]) > 0 {
|
|
|
|
headerNickname = myNicknameList[1]
|
|
|
|
headerNickname = myNicknameList[1]
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("eQSL Nickmane: %s", headerNickname))
|
|
|
|
cleanedInput = append(cleanedInput, fmt.Sprintf("eQSL Nickmane: %s", headerNickname))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -224,12 +223,12 @@ func loadFile() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Date
|
|
|
|
// Date
|
|
|
|
if(regexpHeaderDate.MatchString(eachline)) {
|
|
|
|
if regexpHeaderDate.MatchString(eachline) {
|
|
|
|
errorMsg := ""
|
|
|
|
errorMsg := ""
|
|
|
|
myDateList := regexpHeaderDate.Split(eachline, -1)
|
|
|
|
myDateList := regexpHeaderDate.Split(eachline, -1)
|
|
|
|
if(len(myDateList[1]) > 0) {
|
|
|
|
if len(myDateList[1]) > 0 {
|
|
|
|
headerDate, errorMsg = ValidateDate(myDateList[1])
|
|
|
|
headerDate, errorMsg = ValidateDate(myDateList[1])
|
|
|
|
if(len(errorMsg) != 0) {
|
|
|
|
if len(errorMsg) != 0 {
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid Date at line %d: %s (%s)", lineCount, myDateList[1], errorMsg))
|
|
|
|
errorLog = append(errorLog, fmt.Sprintf("Invalid Date at line %d: %s (%s)", lineCount, myDateList[1], errorMsg))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -279,7 +278,7 @@ func loadFile() {
|
|
|
|
fmt.Print(SprintLogInColumn(filledLogLine))
|
|
|
|
fmt.Print(SprintLogInColumn(filledLogLine))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(len(errorLog) != 0){
|
|
|
|
if len(errorLog) != 0 {
|
|
|
|
fmt.Println("\nProcessing errors:")
|
|
|
|
fmt.Println("\nProcessing errors:")
|
|
|
|
for _, errorLogLine := range errorLog {
|
|
|
|
for _, errorLogLine := range errorLog {
|
|
|
|
fmt.Println(errorLogLine)
|
|
|
|
fmt.Println(errorLogLine)
|
|
|
@ -288,5 +287,4 @@ func loadFile() {
|
|
|
|
fmt.Println("\nSuccesfuly parsed ", lineCount, " lines.")
|
|
|
|
fmt.Println("\nSuccesfuly parsed ", lineCount, " lines.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|