github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/cmd/syft/internal/commands/packages.go (about) 1 package commands 2 3 import ( 4 "github.com/spf13/cobra" 5 6 "github.com/anchore/clio" 7 "github.com/anchore/syft/cmd/syft/internal/ui" 8 "github.com/anchore/syft/internal" 9 ) 10 11 func Packages(app clio.Application, scanCmd *cobra.Command) *cobra.Command { 12 id := app.ID() 13 14 opts := defaultScanOptions() 15 16 cmd := app.SetupCommand(&cobra.Command{ 17 Use: "packages [SOURCE]", 18 Short: scanCmd.Short, 19 Long: scanCmd.Long, 20 Args: scanCmd.Args, 21 Example: internal.Tprintf(scanHelp, map[string]interface{}{ 22 "appName": id.Name, 23 "command": "packages", 24 }), 25 PreRunE: applicationUpdateCheck(id, &opts.UpdateCheck), 26 RunE: func(cmd *cobra.Command, args []string) error { 27 restoreStdout := ui.CaptureStdoutToTraceLog() 28 defer restoreStdout() 29 30 return runScan(cmd.Context(), id, opts, args[0]) 31 }, 32 }, opts) 33 34 cmd.Deprecated = "use `syft scan` instead" 35 36 return cmd 37 }