@@ -22,15 +22,17 @@ THE SOFTWARE.
2222package cmd
2323
2424import (
25+ "fmt"
26+ "os"
27+ "path/filepath"
28+
2529 "github.com/foolin/sumdiff/internal/util"
2630 "github.com/foolin/sumdiff/internal/vlog"
2731 "github.com/foolin/sumdiff/internal/write"
2832 "github.com/spf13/cobra"
29- "os"
30- "path/filepath"
3133)
3234
33- var config Config
35+ var config * Config
3436var writer * write.Writer
3537var file * os.File
3638
@@ -43,18 +45,21 @@ var rootCmd = &cobra.Command{
4345 // has an action associated with it:
4446 // Run: func(cmd *cobra.Command, args []string) { },
4547 PersistentPreRun : func (cmd * cobra.Command , args []string ) {
48+
49+ fmt .Printf ("Config: %#v" , config )
4650 //Verbose
4751 vlog .SetVerbose (config .Verbose )
4852
4953 //Write
5054 t := write .Table
51- if config .Format != "" {
55+ if config .Type != "" {
5256 var ok bool
53- t , ok = write .TypeOfName (config .Format )
57+ t , ok = write .TypeOfName (config .Type )
5458 if ! ok {
55- vlog .Exit (1 , "Format invalid: %v\n " , config .Format )
59+ vlog .Exit (1 , "Format invalid: %v\n " , config .Type )
5660 return
5761 }
62+ fmt .Printf ("Parse type: %v\n " , t )
5863 }
5964
6065 w := os .Stdout
@@ -98,14 +103,14 @@ func init() {
98103 // Cobra supports persistent flags, which, if defined here,
99104 // will be global for your application.
100105
101- config = Config {
106+ config = & Config {
102107 Verbose : false ,
103- Format : " " ,
108+ Type : "table " ,
104109 Output : "" ,
105110 }
106111 // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.sumdiff.yaml)")
107112 rootCmd .PersistentFlags ().BoolVarP (& config .Verbose , "verbose" , "v" , false , "Verbose output info" )
108- rootCmd .PersistentFlags ().StringVarP (& config .Format , "format " , "f " , "table" , "Format: table|json|csv|yaml" )
113+ rootCmd .PersistentFlags ().StringVarP (& config .Type , "type " , "t " , "table" , "Format: table|json|csv|yaml" )
109114 rootCmd .PersistentFlags ().StringVarP (& config .Output , "output" , "o" , "" , "Output filename" )
110115
111116 // Cobra also supports local flags, which will only run
0 commit comments