@@ -22,7 +22,6 @@ THE SOFTWARE.
2222package cmd
2323
2424import (
25- "fmt"
2625 "os"
2726 "path/filepath"
2827
@@ -45,21 +44,18 @@ var rootCmd = &cobra.Command{
4544 // has an action associated with it:
4645 // Run: func(cmd *cobra.Command, args []string) { },
4746 PersistentPreRun : func (cmd * cobra.Command , args []string ) {
48-
49- fmt .Printf ("Config: %#v" , config )
5047 //Verbose
5148 vlog .SetVerbose (config .Verbose )
5249
5350 //Write
54- t := write .Table
55- if config .Type != "" {
51+ format := write .Table
52+ if config .Format != "" {
5653 var ok bool
57- t , ok = write .TypeOfName (config .Type )
54+ format , ok = write .FormatOfName (config .Format )
5855 if ! ok {
59- vlog .Exit (1 , "Format invalid: %v\n " , config .Type )
56+ vlog .Exit (1 , "Format invalid: %v\n " , config .Format )
6057 return
6158 }
62- fmt .Printf ("Parse type: %v\n " , t )
6359 }
6460
6561 w := os .Stdout
@@ -76,7 +72,7 @@ var rootCmd = &cobra.Command{
7672 }
7773
7874 //Create writer
79- writer = write .New (w , t )
75+ writer = write .New (w , format )
8076 },
8177 PersistentPostRun : func (cmd * cobra.Command , args []string ) {
8278 if file != nil {
@@ -105,12 +101,12 @@ func init() {
105101
106102 config = & Config {
107103 Verbose : false ,
108- Type : "table" ,
104+ Format : "table" ,
109105 Output : "" ,
110106 }
111107 // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.sumdiff.yaml)")
112108 rootCmd .PersistentFlags ().BoolVarP (& config .Verbose , "verbose" , "v" , false , "Verbose output info" )
113- rootCmd .PersistentFlags ().StringVarP (& config .Type , "type " , "t " , "table" , "Format: table|json|csv|yaml" )
109+ rootCmd .PersistentFlags ().StringVarP (& config .Format , "format " , "f " , "table" , "Format: table|json|csv|yaml" )
114110 rootCmd .PersistentFlags ().StringVarP (& config .Output , "output" , "o" , "" , "Output filename" )
115111
116112 // Cobra also supports local flags, which will only run
0 commit comments