From 9c903913ac66683ff3ab4e830056201cc060ae91 Mon Sep 17 00:00:00 2001 From: Jean-Marc MEESSEN Date: Sun, 28 Jun 2020 14:52:24 +0200 Subject: [PATCH] some command line tweaking --- cmd/adif.go | 22 ++++++++++++++++++---- cmd/root.go | 4 +++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/cmd/adif.go b/cmd/adif.go index 6fe1a46..e96d3db 100644 --- a/cmd/adif.go +++ b/cmd/adif.go @@ -23,6 +23,9 @@ import ( //"strings" ) +var outputFilename string +var isWwff bool + // adifCmd is executed when choosing the adif option (load and generate adif file) var adifCmd = &cobra.Command{ Use: "adif", @@ -31,14 +34,25 @@ var adifCmd = &cobra.Command{ // and usage of using your command. For example: Run: func(cmd *cobra.Command, args []string) { - fmt.Println("adif called") - fmt.Println("Inputfile: ", inputFilename) - loadFile() + processAdifCommand() }, } func init() { rootCmd.AddCommand(adifCmd) - adifCmd.PersistentFlags().BoolP("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().StringVarP(&outputFilename, "output", "o", "", "Output filename") } + +func processAdifCommand(){ + + verifiedOutputFilename, wasOK := buildOutputFilename(outputFilename,inputFilename,false) + 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) + //loadFile() +} \ No newline at end of file diff --git a/cmd/root.go b/cmd/root.go index 2108478..05adb29 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -35,6 +35,7 @@ import ( var cfgFile string var inputFilename string + // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "FLEcli", @@ -65,7 +66,8 @@ func init() { rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.FLEcli.yaml)") - rootCmd.PersistentFlags().StringVarP(&inputFilename, "inputFilename", "i", "", "FLE formatted input file") + rootCmd.PersistentFlags().StringVarP(&inputFilename, "input", "i", "", "FLE formatted input file") + rootCmd.MarkFlagRequired("input") } // initConfig reads in config file and ENV variables if set.