@@ -117,11 +117,16 @@ func Build[T configuration.Config](
117117 if err != nil {
118118 return err
119119 }
120- return WriteConfig (builder .filesystem , cfg , outPath )
120+ overwrite , err := cmd .Flags ().GetBool ("force" )
121+ if err != nil {
122+ return err
123+ }
124+ return WriteConfig (builder .filesystem , cfg , outPath , overwrite )
121125 },
122126 }
123127 genConfigCmd .PersistentFlags ().String ("output" , "" , "output file" )
124128 genConfigCmd .MarkPersistentFlagRequired ("output" )
129+ genConfigCmd .PersistentFlags ().BoolP ("force" , "f" , false , "overwrite existing file" )
125130 cb .cobraCommand .AddCommand (genConfigCmd )
126131 }
127132 if builder .dumpConfig {
@@ -145,13 +150,18 @@ func Build[T configuration.Config](
145150 log .Debug ().
146151 Interface ("config" , cfg ).
147152 Msg ("dumping config" )
148- return WriteConfig (builder .filesystem , cfg , outPath )
153+ overwrite , err := cmd .Flags ().GetBool ("force" )
154+ if err != nil {
155+ return err
156+ }
157+ return WriteConfig (builder .filesystem , cfg , outPath , overwrite )
149158 },
150159 }
151160 dumpConfigCmd .PersistentFlags ().String ("output" , "" , "output file" )
152161 dumpConfigCmd .MarkPersistentFlagRequired ("output" )
153162 dumpConfigCmd .PersistentFlags ().String ("config" , "" , "config file" )
154163 dumpConfigCmd .MarkPersistentFlagFilename ("config" )
164+ dumpConfigCmd .PersistentFlags ().BoolP ("force" , "f" , false , "overwrite existing file" )
155165 cb .cobraCommand .AddCommand (dumpConfigCmd )
156166 }
157167 return cb
0 commit comments