Prepare everything to write the adif

pull/2/head
Jean-Marc MEESSEN 4 years ago
parent 76389cdf55
commit 8cae1aa940

@ -42,14 +42,14 @@ var adifCmd = &cobra.Command{
func init() { func init() {
rootCmd.AddCommand(adifCmd) rootCmd.AddCommand(adifCmd)
adifCmd.PersistentFlags().BoolVarP(&isWwff,"wwff", "w", false, "Generates an ADIF file ready to be uploaded on WWFF") adifCmd.PersistentFlags().BoolVarP(&isWwff, "wwff", "w", false, "Generates an ADIF file ready to be uploaded on WWFF")
adifCmd.PersistentFlags().BoolVarP(&isOverwrite,"overWrite", "", false, "Overwrites the output file if it exisits") adifCmd.PersistentFlags().BoolVarP(&isOverwrite, "overwrite", "", false, "Overwrites the output file if it exisits")
adifCmd.PersistentFlags().StringVarP(&outputFilename, "output", "o", "", "Output filename") adifCmd.PersistentFlags().StringVarP(&outputFilename, "output", "o", "", "Output filename")
} }
func processAdifCommand(){ func processAdifCommand() {
verifiedOutputFilename, wasOK := buildOutputFilename(outputFilename,inputFilename,isOverwrite) verifiedOutputFilename, wasOK := buildOutputFilename(outputFilename, inputFilename, isOverwrite)
fmt.Println("adif called") fmt.Println("adif called")
fmt.Println("Inputfile: ", inputFilename) fmt.Println("Inputfile: ", inputFilename)
fmt.Println("OutputFile: ", outputFilename) fmt.Println("OutputFile: ", outputFilename)
@ -57,5 +57,14 @@ func processAdifCommand(){
fmt.Println("Output wasOK: ", wasOK) fmt.Println("Output wasOK: ", wasOK)
fmt.Println("wwff: ", isWwff) fmt.Println("wwff: ", isWwff)
fmt.Println("isOverwrite: ", isOverwrite) fmt.Println("isOverwrite: ", isOverwrite)
//loadFile()
// if the output file could not be parsed correctly do noting
if wasOK {
loadedLogFile, isLoadedOK := loadFile()
if isLoadedOK {
//check if we have the necessary information for the type
writeAdif(verifiedOutputFilename, loadedLogFile)
}
}
} }

@ -16,6 +16,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
// does the target file exist? func writeAdif(outputFile string, fullLog []LogLine) {
// is the file defined
// remove the extention // TODO: create an array of strings first
// TODO: write the array list to file
}

@ -57,9 +57,8 @@ func init() {
// loadCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") // loadCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
} }
//returns nill if failure to process //returns nill if failure to process
func loadFile() (filleFullLog []LogLine) { func loadFile() (filleFullLog []LogLine, isProcessedOK bool) {
file, err := os.Open(inputFilename) file, err := os.Open(inputFilename)
if err != nil { if err != nil {
@ -275,12 +274,13 @@ func loadFile() (filleFullLog []LogLine) {
for _, errorLogLine := range errorLog { for _, errorLogLine := range errorLog {
fmt.Println(errorLogLine) fmt.Println(errorLogLine)
} }
return nil isProcessedOK = false
} else { }else {
fmt.Println("\nSuccesfuly parsed ", lineCount, " lines.") fmt.Println("\nSuccesfuly parsed ", lineCount, " lines.")
isProcessedOK = true
} }
return fullLog return fullLog, isProcessedOK
} }
@ -297,4 +297,3 @@ func displayLogSimple(fullLog []LogLine) {
} }
} }

Loading…
Cancel
Save