Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up config help text #2347

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func DBCheck(app clio.Application) *cobra.Command {
DBOptions: *dbOptionsDefault(app.ID()),
}

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "check",
Short: "check to see if there is a database update available",
PreRunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -48,7 +48,14 @@ func DBCheck(app clio.Application) *cobra.Command {
RunE: func(_ *cobra.Command, _ []string) error {
return runDBCheck(*opts)
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbCheckOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}

func runDBCheck(opts dbCheckOptions) error {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@ import (
func DBDelete(app clio.Application) *cobra.Command {
opts := dbOptionsDefault(app.ID())

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "delete",
Short: "delete the vulnerability database",
Args: cobra.ExactArgs(0),
PreRunE: disableUI(app),
RunE: func(_ *cobra.Command, _ []string) error {
return runDBDelete(*opts)
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *DBOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}

func runDBDelete(opts DBOptions) error {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func DBDiff(app clio.Application) *cobra.Command {
DBOptions: *dbOptionsDefault(app.ID()),
}

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "diff [flags] base_db_url target_db_url",
Short: "diff two DBs and display the result",
Args: cobra.MaximumNArgs(2),
Expand Down Expand Up @@ -61,7 +61,14 @@ func DBDiff(app clio.Application) *cobra.Command {

return runDBDiff(opts, base, target)
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbDiffOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}

func runDBDiff(opts *dbDiffOptions, base string, target string) (errs error) {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@ import (
func DBImport(app clio.Application) *cobra.Command {
opts := dbOptionsDefault(app.ID())

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "import FILE",
Short: "import a vulnerability database archive",
Long: fmt.Sprintf("import a vulnerability database archive from a local FILE.\nDB archives can be obtained from %q.", internal.DBUpdateURL),
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
return runDBImport(*opts, args[0])
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *DBOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}

func runDBImport(opts DBOptions, dbArchivePath string) error {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,22 @@ func DBList(app clio.Application) *cobra.Command {
DBOptions: *dbOptionsDefault(app.ID()),
}

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "list",
Short: "list all DBs available according to the listing URL",
PreRunE: disableUI(app),
Args: cobra.ExactArgs(0),
RunE: func(_ *cobra.Command, _ []string) error {
return runDBList(*opts)
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbListOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}

func runDBList(opts dbListOptions) error {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,21 @@ func DBProviders(app clio.Application) *cobra.Command {
DBOptions: *dbOptionsDefault(app.ID()),
}

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "providers",
Short: "list vulnerability database providers",
Args: cobra.ExactArgs(0),
RunE: func(_ *cobra.Command, _ []string) error {
return runDBProviders(opts, app)
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbProvidersOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}

func runDBProviders(opts *dbProvidersOptions, app clio.Application) error {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@ func DBSearch(app clio.Application) *cobra.Command {
DBOptions: *dbOptionsDefault(app.ID()),
}

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "search [vulnerability_id]",
Short: "get information on a vulnerability from the db",
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) (err error) {
id := args[0]
return runDBSearch(*opts, id)
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbQueryOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}

func runDBSearch(opts dbQueryOptions, vulnerabilityID string) error {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,22 @@ func DBStatus(app clio.Application) *cobra.Command {
DBOptions: *dbOptionsDefault(app.ID()),
}

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "status",
Short: "display database status",
Args: cobra.ExactArgs(0),
PreRunE: disableUI(app),
RunE: func(_ *cobra.Command, _ []string) error {
return runDBStatus(*opts)
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *dbStatusOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}

func runDBStatus(opts dbStatusOptions) error {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/db_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
func DBUpdate(app clio.Application) *cobra.Command {
opts := dbOptionsDefault(app.ID())

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "update",
Short: "download the latest vulnerability database",
Args: cobra.ExactArgs(0),
Expand All @@ -29,7 +29,14 @@ func DBUpdate(app clio.Application) *cobra.Command {
RunE: func(_ *cobra.Command, _ []string) error {
return runDBUpdate(opts.DB, opts.Experimental.DBv6)
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *DBOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}

func runDBUpdate(opts options.Database, expUseV6 bool) error {
Expand Down
11 changes: 9 additions & 2 deletions cmd/grype/cli/commands/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (d *explainOptions) AddFlags(flags clio.FlagSet) {
func Explain(app clio.Application) *cobra.Command {
opts := &explainOptions{}

return app.SetupCommand(&cobra.Command{
cmd := &cobra.Command{
Use: "explain --id [VULNERABILITY ID]",
Short: "Ask grype to explain a set of findings",
PreRunE: disableUI(app),
Expand All @@ -53,5 +53,12 @@ func Explain(app clio.Application) *cobra.Command {
// TODO: implement
return fmt.Errorf("requires grype json on stdin, please run 'grype -o json ... | grype explain ...'")
},
}, opts)
}

// prevent from being shown in the grype config
type configWrapper struct {
Opts *explainOptions `json:"-" yaml:"-" mapstructure:"-"`
}

return app.SetupCommand(cmd, &configWrapper{opts})
}
Loading