mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
* internalize majority of cmd package and migrate integration tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add internal api encoder Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * create internal representation of all formats Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * export capability to get default encoders Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * restore test fixtures Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
33 lines
716 B
Go
33 lines
716 B
Go
package options
|
|
|
|
import (
|
|
"github.com/anchore/clio"
|
|
"github.com/anchore/syft/syft/format/template"
|
|
)
|
|
|
|
var _ clio.FlagAdder = (*FormatTemplate)(nil)
|
|
|
|
type FormatTemplate struct {
|
|
Enabled bool `yaml:"-" json:"-" mapstructure:"-"`
|
|
Path string `yaml:"path" json:"path" mapstructure:"path"` // -t template file to use for output
|
|
}
|
|
|
|
func DefaultFormatTemplate() FormatTemplate {
|
|
return FormatTemplate{
|
|
Enabled: true,
|
|
}
|
|
}
|
|
|
|
func (o *FormatTemplate) AddFlags(flags clio.FlagSet) {
|
|
if o.Enabled {
|
|
flags.StringVarP(&o.Path, "template", "t",
|
|
"specify the path to a Go template file")
|
|
}
|
|
}
|
|
|
|
func (o FormatTemplate) config() template.EncoderConfig {
|
|
return template.EncoderConfig{
|
|
TemplatePath: o.Path,
|
|
}
|
|
}
|