From 21878784a8babc3931a3ecc394c4ced7d81aabfd Mon Sep 17 00:00:00 2001 From: Mohammad Sharief Baig <56253776+sharief007@users.noreply.github.com> Date: Tue, 3 Oct 2023 20:43:07 +0530 Subject: [PATCH] chore: improve --output help text and deprecate --file (#2187) Signed-off-by: Mohammad Sharief Baig --- cmd/syft/cli/options/output.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/syft/cli/options/output.go b/cmd/syft/cli/options/output.go index 034742757..09c226f3e 100644 --- a/cmd/syft/cli/options/output.go +++ b/cmd/syft/cli/options/output.go @@ -5,6 +5,7 @@ import ( "slices" "github.com/anchore/clio" + "github.com/anchore/fangs" "github.com/anchore/syft/syft/formats" "github.com/anchore/syft/syft/formats/table" "github.com/anchore/syft/syft/formats/template" @@ -30,7 +31,7 @@ func DefaultOutput() MultiOutput { func (o *MultiOutput) AddFlags(flags clio.FlagSet) { flags.StringArrayVarP(&o.Outputs, "output", "o", - fmt.Sprintf("report output format, options=%v", formats.AllIDs())) + fmt.Sprintf("report output format (= to output to a file), formats=%v", formats.AllIDs())) flags.StringVarP(&o.OutputTemplatePath, "template", "t", "specify the path to a Go template file") @@ -63,7 +64,7 @@ func (o *SingleOutput) SBOMWriter(file string) (sbom.Writer, error) { return makeSBOMWriter([]string{o.Output}, file, o.OutputTemplatePath) } -// OutputFile is only the --file argument +// Deprecated: OutputFile is only the --file argument type OutputFile struct { File string `yaml:"file" json:"file" mapstructure:"file"` // --file, the file to write report output to } @@ -76,6 +77,11 @@ var _ interface { func (o *OutputFile) AddFlags(flags clio.FlagSet) { flags.StringVarP(&o.File, "file", "", "file to write the default report output to (default is STDOUT)") + + if pfp, ok := flags.(fangs.PFlagSetProvider); ok { + flagSet := pfp.PFlagSet() + flagSet.Lookup("file").Deprecated = "use: output" + } } func (o *OutputFile) PostLoad() error {