github.com/kastenhq/syft@v0.0.0-20230821225854-0710af25cdbe/cmd/syft/cli/poweruser.go (about) 1 package cli 2 3 import ( 4 "fmt" 5 6 "github.com/spf13/cobra" 7 "github.com/spf13/viper" 8 9 "github.com/kastenhq/syft/cmd/syft/cli/options" 10 "github.com/kastenhq/syft/cmd/syft/cli/poweruser" 11 "github.com/kastenhq/syft/internal" 12 "github.com/kastenhq/syft/internal/config" 13 ) 14 15 const powerUserExample = ` {{.appName}} {{.command}} <image> 16 DEPRECATED - THIS COMMAND WILL BE REMOVED in v1.0.0 17 Only image sources are supported (e.g. docker: , podman: , docker-archive: , oci: , etc.), the directory source (dir:) is not supported, template outputs are not supported. 18 All behavior is controlled via application configuration and environment variables (see https://github.com/anchore/syft#configuration) 19 ` 20 21 func PowerUser(v *viper.Viper, app *config.Application, ro *options.RootOptions) *cobra.Command { 22 cmd := &cobra.Command{ 23 Use: "power-user [IMAGE]", 24 Short: "Run bulk operations on container images", 25 Example: internal.Tprintf(powerUserExample, map[string]interface{}{ 26 "appName": internal.ApplicationName, 27 "command": "power-user", 28 }), 29 Args: func(cmd *cobra.Command, args []string) error { 30 if err := app.LoadAllValues(v, ro.Config); err != nil { 31 return fmt.Errorf("invalid application config: %w", err) 32 } 33 // configure logging for command 34 newLogWrapper(app) 35 logApplicationConfig(app) 36 return validateArgs(cmd, args) 37 }, 38 Hidden: true, 39 SilenceUsage: true, 40 SilenceErrors: true, 41 RunE: func(cmd *cobra.Command, args []string) error { 42 if app.CheckForAppUpdate { 43 checkForApplicationUpdate() 44 // TODO: this is broke, the bus isn't available yet 45 } 46 return poweruser.Run(cmd.Context(), app, args) 47 }, 48 } 49 50 return cmd 51 }