@@ -31,17 +31,18 @@ import (
3131)
3232
3333const (
34- asFileDescriptorSetFlagName = "as-file-descriptor-set"
35- errorFormatFlagName = "error-format"
36- excludeImportsFlagName = "exclude-imports"
37- excludeSourceInfoFlagName = "exclude-source-info"
38- pathsFlagName = "path"
39- outputFlagName = "output"
40- outputFlagShortName = "o"
41- configFlagName = "config"
42- excludePathsFlagName = "exclude-path"
43- disableSymlinksFlagName = "disable-symlinks"
44- typeFlagName = "type"
34+ asFileDescriptorSetFlagName = "as-file-descriptor-set"
35+ errorFormatFlagName = "error-format"
36+ excludeImportsFlagName = "exclude-imports"
37+ excludeSourceInfoFlagName = "exclude-source-info"
38+ excludeSourceRetentionOptionsFlagName = "exclude-source-retention-options"
39+ pathsFlagName = "path"
40+ outputFlagName = "output"
41+ outputFlagShortName = "o"
42+ configFlagName = "config"
43+ excludePathsFlagName = "exclude-path"
44+ disableSymlinksFlagName = "disable-symlinks"
45+ typeFlagName = "type"
4546)
4647
4748// NewCommand returns a new Command.
@@ -66,16 +67,17 @@ func NewCommand(
6667}
6768
6869type flags struct {
69- AsFileDescriptorSet bool
70- ErrorFormat string
71- ExcludeImports bool
72- ExcludeSourceInfo bool
73- Paths []string
74- Output string
75- Config string
76- ExcludePaths []string
77- DisableSymlinks bool
78- Types []string
70+ AsFileDescriptorSet bool
71+ ErrorFormat string
72+ ExcludeImports bool
73+ ExcludeSourceInfo bool
74+ ExcludeSourceRetentionOptions bool
75+ Paths []string
76+ Output string
77+ Config string
78+ ExcludePaths []string
79+ DisableSymlinks bool
80+ Types []string
7981 // special
8082 InputHashtag string
8183}
@@ -92,6 +94,12 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) {
9294 bufcli .BindPaths (flagSet , & f .Paths , pathsFlagName )
9395 bufcli .BindExcludePaths (flagSet , & f .ExcludePaths , excludePathsFlagName )
9496 bufcli .BindDisableSymlinks (flagSet , & f .DisableSymlinks , disableSymlinksFlagName )
97+ flagSet .BoolVar (
98+ & f .ExcludeSourceRetentionOptions ,
99+ excludeSourceRetentionOptionsFlagName ,
100+ false ,
101+ "Exclude options whose retention is source" ,
102+ )
95103 flagSet .StringVar (
96104 & f .ErrorFormat ,
97105 errorFormatFlagName ,
@@ -165,6 +173,12 @@ func run(
165173 return err
166174 }
167175 }
176+ if flags .ExcludeSourceRetentionOptions {
177+ image , err = bufimageutil .StripSourceRetentionOptions (image )
178+ if err != nil {
179+ return err
180+ }
181+ }
168182 return bufcli .NewWireImageWriter (
169183 container .Logger (),
170184 ).PutImage (
0 commit comments