mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
* internalize majority of cmd package and migrate integration tests Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * add internal api encoder Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * create internal representation of all formats Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * export capability to get default encoders Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * restore test fixtures Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
32 lines
742 B
Go
32 lines
742 B
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/anchore/clio"
|
|
"github.com/anchore/syft/cmd/syft/internal/ui"
|
|
)
|
|
|
|
func Root(app clio.Application, packagesCmd *cobra.Command) *cobra.Command {
|
|
id := app.ID()
|
|
|
|
opts := defaultScanOptions()
|
|
|
|
return app.SetupRootCommand(&cobra.Command{
|
|
Use: fmt.Sprintf("%s [SOURCE]", app.ID().Name),
|
|
Short: packagesCmd.Short,
|
|
Long: packagesCmd.Long,
|
|
Args: packagesCmd.Args,
|
|
Example: packagesCmd.Example,
|
|
PreRunE: applicationUpdateCheck(id, &opts.UpdateCheck),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
restoreStdout := ui.CaptureStdoutToTraceLog()
|
|
defer restoreStdout()
|
|
|
|
return runScan(cmd.Context(), id, opts, args[0])
|
|
},
|
|
}, opts)
|
|
}
|