mirror of
https://github.com/anchore/syft
synced 2024-11-10 14:24:12 +00:00
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/anchore/imgbom/imgbom/presenter"
|
|
"github.com/anchore/imgbom/imgbom/scope"
|
|
"github.com/anchore/imgbom/internal/config"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
var cliOpts = config.CliOnlyOptions{}
|
|
|
|
func setCliOptions() {
|
|
rootCmd.PersistentFlags().StringVarP(&cliOpts.ConfigPath, "config", "c", "", "application config file")
|
|
|
|
// scan options
|
|
flag := "scope"
|
|
rootCmd.Flags().StringP(
|
|
"scope", "s", scope.AllLayersScope.String(),
|
|
fmt.Sprintf("selection of layers to analyze, options=%v", scope.Options))
|
|
if err := viper.BindPFlag(flag, rootCmd.Flags().Lookup(flag)); err != nil {
|
|
fmt.Printf("unable to bind flag '%s': %+v", flag, err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// output & formatting options
|
|
flag = "output"
|
|
rootCmd.Flags().StringP(
|
|
flag, "o", presenter.JSONPresenter.String(),
|
|
fmt.Sprintf("report output formatter, options=%v", presenter.Options),
|
|
)
|
|
if err := viper.BindPFlag(flag, rootCmd.Flags().Lookup(flag)); err != nil {
|
|
fmt.Printf("unable to bind flag '%s': %+v", flag, err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
flag = "quiet"
|
|
rootCmd.Flags().BoolP(
|
|
flag, "q", false,
|
|
"suppress all logging output",
|
|
)
|
|
if err := viper.BindPFlag(flag, rootCmd.Flags().Lookup(flag)); err != nil {
|
|
fmt.Printf("unable to bind flag '%s': %+v", flag, err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
rootCmd.Flags().CountVarP(&cliOpts.Verbosity, "verbose", "v", "increase verbosity (-v = info, -vv = debug)")
|
|
}
|