From 8cae1aa940826f349cea0a256d4702ff67dd9a85 Mon Sep 17 00:00:00 2001 From: Jean-Marc MEESSEN Date: Mon, 29 Jun 2020 13:55:11 +0200 Subject: [PATCH] Prepare everything to write the adif --- cmd/adif.go | 25 +++++++++++++++++-------- cmd/adif_write.go | 8 +++++--- cmd/load.go | 11 +++++------ 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/cmd/adif.go b/cmd/adif.go index a65fbea..2164a57 100644 --- a/cmd/adif.go +++ b/cmd/adif.go @@ -42,20 +42,29 @@ var adifCmd = &cobra.Command{ func init() { rootCmd.AddCommand(adifCmd) - 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(&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().StringVarP(&outputFilename, "output", "o", "", "Output filename") } -func processAdifCommand(){ - - verifiedOutputFilename, wasOK := buildOutputFilename(outputFilename,inputFilename,isOverwrite) +func processAdifCommand() { + + verifiedOutputFilename, wasOK := buildOutputFilename(outputFilename, inputFilename, isOverwrite) fmt.Println("adif called") fmt.Println("Inputfile: ", inputFilename) fmt.Println("OutputFile: ", outputFilename) fmt.Println("computed output: ", verifiedOutputFilename) fmt.Println("Output wasOK: ", wasOK) - fmt.Println("wwff: ", isWwff) + fmt.Println("wwff: ", isWwff) fmt.Println("isOverwrite: ", isOverwrite) - //loadFile() -} \ No newline at end of file + + // 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) + } + } +} diff --git a/cmd/adif_write.go b/cmd/adif_write.go index 68fcd39..d1a7934 100644 --- a/cmd/adif_write.go +++ b/cmd/adif_write.go @@ -16,6 +16,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -// does the target file exist? -// is the file defined -// remove the extention +func writeAdif(outputFile string, fullLog []LogLine) { + +// TODO: create an array of strings first +// TODO: write the array list to file +} diff --git a/cmd/load.go b/cmd/load.go index b550f9c..f071b4b 100644 --- a/cmd/load.go +++ b/cmd/load.go @@ -57,9 +57,8 @@ func init() { // loadCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") } - //returns nill if failure to process -func loadFile() (filleFullLog []LogLine) { +func loadFile() (filleFullLog []LogLine, isProcessedOK bool) { file, err := os.Open(inputFilename) if err != nil { @@ -275,12 +274,13 @@ func loadFile() (filleFullLog []LogLine) { for _, errorLogLine := range errorLog { fmt.Println(errorLogLine) } - return nil - } else { + isProcessedOK = false + }else { fmt.Println("\nSuccesfuly parsed ", lineCount, " lines.") + isProcessedOK = true } - return fullLog + return fullLog, isProcessedOK } @@ -297,4 +297,3 @@ func displayLogSimple(fullLog []LogLine) { } } -