github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/cmd/gosbom/cli/poweruser.go (about) 1 package cli 2 3 import ( 4 "fmt" 5 6 "github.com/nextlinux/gosbom/cmd/gosbom/cli/options" 7 "github.com/nextlinux/gosbom/cmd/gosbom/cli/poweruser" 8 "github.com/nextlinux/gosbom/internal" 9 "github.com/nextlinux/gosbom/internal/config" 10 "github.com/spf13/cobra" 11 "github.com/spf13/viper" 12 ) 13 14 const powerUserExample = ` {{.appName}} {{.command}} <image> 15 DEPRECATED - THIS COMMAND WILL BE REMOVED in v1.0.0 16 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. 17 All behavior is controlled via application configuration and environment variables (see https://github.com/nextlinux/gosbom#configuration) 18 ` 19 20 func PowerUser(v *viper.Viper, app *config.Application, ro *options.RootOptions) *cobra.Command { 21 cmd := &cobra.Command{ 22 Use: "power-user [IMAGE]", 23 Short: "Run bulk operations on container images", 24 Example: internal.Tprintf(powerUserExample, map[string]interface{}{ 25 "appName": internal.ApplicationName, 26 "command": "power-user", 27 }), 28 Args: func(cmd *cobra.Command, args []string) error { 29 if err := app.LoadAllValues(v, ro.Config); err != nil { 30 return fmt.Errorf("invalid application config: %w", err) 31 } 32 // configure logging for command 33 newLogWrapper(app) 34 logApplicationConfig(app) 35 return validateArgs(cmd, args) 36 }, 37 Hidden: true, 38 SilenceUsage: true, 39 SilenceErrors: true, 40 RunE: func(cmd *cobra.Command, args []string) error { 41 if app.CheckForAppUpdate { 42 checkForApplicationUpdate() 43 } 44 return poweruser.Run(cmd.Context(), app, args) 45 }, 46 } 47 48 return cmd 49 }