@@ -15,7 +15,7 @@ var generateCmd = &cobra.Command{
1515 Use : "generate" ,
1616 Short : "Generate a config_db.json" ,
1717 Run : func (cmd * cobra.Command , args []string ) {
18- configDBFile , _ := cmd .Flags ().GetString ("output " )
18+ configDBFile , _ := cmd .Flags ().GetString ("config-db " )
1919 configDBBytes , err := os .ReadFile (configDBFile )
2020 if err != nil {
2121 fmt .Printf ("failed to read current config file, %v\n " , err )
@@ -44,7 +44,7 @@ var generateCmd = &cobra.Command{
4444 os .Exit (1 )
4545 }
4646
47- inputFile , _ := cmd .Flags ().GetString ("input" )
47+ inputFile , _ := cmd .Flags ().GetString ("input-file " )
4848 inputBytes , err := os .ReadFile (inputFile )
4949 if err != nil {
5050 fmt .Printf ("failed to read input file, %v\n " , err )
@@ -69,7 +69,8 @@ var generateCmd = &cobra.Command{
6969 os .Exit (1 )
7070 }
7171
72- err = os .WriteFile (configDBFile , configDBBytes , 0644 ) //nolint:gosec
72+ outputFile , _ := cmd .Flags ().GetString ("output-file" )
73+ err = os .WriteFile (outputFile , configDBBytes , 0644 ) //nolint:gosec
7374 if err != nil {
7475 fmt .Printf ("failed to write file, %v" , err )
7576 os .Exit (1 )
@@ -80,7 +81,8 @@ var generateCmd = &cobra.Command{
8081func init () {
8182 rootCmd .AddCommand (generateCmd )
8283
83- generateCmd .Flags ().StringP ("input" , "i" , "sonic-config.yaml" , "path to input file to generate the config_db.json from" )
84- generateCmd .Flags ().StringP ("output" , "o" , "/etc/sonic/ config_db.json" , "path to output file" )
84+ generateCmd .Flags ().StringP ("input-file " , "i" , "sonic-config.yaml" , "path to input file to generate the config_db.json from" )
85+ generateCmd .Flags ().StringP ("output-file " , "o" , "config_db.json" , "path to output file" )
8586 generateCmd .Flags ().String ("device-dir" , "/usr/share/sonic/device" , "directory which holds all device-specific files" )
87+ generateCmd .Flags ().StringP ("config-db" , "c" , "/etc/sonic/config_db.json" , "path to current config_db.json" )
8688}
0 commit comments