github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/cmd/syft/internal/options/format_template.go (about) 1 package options 2 3 import ( 4 "github.com/anchore/clio" 5 "github.com/anchore/syft/syft/format/template" 6 ) 7 8 var _ clio.FlagAdder = (*FormatTemplate)(nil) 9 10 type FormatTemplate struct { 11 Enabled bool `yaml:"-" json:"-" mapstructure:"-"` 12 Path string `yaml:"path" json:"path" mapstructure:"path"` // -t template file to use for output 13 Legacy bool `yaml:"legacy" json:"legacy" mapstructure:"legacy"` 14 } 15 16 func DefaultFormatTemplate() FormatTemplate { 17 return FormatTemplate{ 18 Enabled: true, 19 } 20 } 21 22 func (o *FormatTemplate) AddFlags(flags clio.FlagSet) { 23 if o.Enabled { 24 flags.StringVarP(&o.Path, "template", "t", 25 "specify the path to a Go template file") 26 } 27 } 28 29 func (o FormatTemplate) config() template.EncoderConfig { 30 return template.EncoderConfig{ 31 TemplatePath: o.Path, 32 Legacy: o.Legacy, 33 } 34 }