mirror of
https://github.com/anchore/syft.git
synced 2026-02-12 10:36:45 +01:00
add exit on cli bind fails + copy update
This commit is contained in:
parent
ae6feed8fc
commit
51c972ad33
@ -2,6 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/anchore/imgbom/imgbom/presenter"
|
"github.com/anchore/imgbom/imgbom/presenter"
|
||||||
"github.com/anchore/imgbom/imgbom/scope"
|
"github.com/anchore/imgbom/imgbom/scope"
|
||||||
@ -21,6 +22,7 @@ func setCliOptions() {
|
|||||||
fmt.Sprintf("selection of layers to analyze, options=%v", scope.Options))
|
fmt.Sprintf("selection of layers to analyze, options=%v", scope.Options))
|
||||||
if err := viper.BindPFlag(flag, rootCmd.Flags().Lookup(flag)); err != nil {
|
if err := viper.BindPFlag(flag, rootCmd.Flags().Lookup(flag)); err != nil {
|
||||||
fmt.Printf("unable to bind flag '%s': %+v", flag, err)
|
fmt.Printf("unable to bind flag '%s': %+v", flag, err)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// output & formatting options
|
// output & formatting options
|
||||||
@ -31,15 +33,17 @@ func setCliOptions() {
|
|||||||
)
|
)
|
||||||
if err := viper.BindPFlag(flag, rootCmd.Flags().Lookup(flag)); err != nil {
|
if err := viper.BindPFlag(flag, rootCmd.Flags().Lookup(flag)); err != nil {
|
||||||
fmt.Printf("unable to bind flag '%s': %+v", flag, err)
|
fmt.Printf("unable to bind flag '%s': %+v", flag, err)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
flag = "quiet"
|
flag = "quiet"
|
||||||
rootCmd.Flags().BoolP(
|
rootCmd.Flags().BoolP(
|
||||||
flag, "q", false,
|
flag, "q", false,
|
||||||
"suppress all auxiliary output",
|
"suppress all logging output",
|
||||||
)
|
)
|
||||||
if err := viper.BindPFlag(flag, rootCmd.Flags().Lookup(flag)); err != nil {
|
if err := viper.BindPFlag(flag, rootCmd.Flags().Lookup(flag)); err != nil {
|
||||||
fmt.Printf("unable to bind flag '%s': %+v", flag, err)
|
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)")
|
rootCmd.Flags().CountVarP(&cliOpts.Verbosity, "verbose", "v", "increase verbosity (-v = info, -vv = debug)")
|
||||||
|
|||||||
@ -85,7 +85,9 @@ func (cfg *Application) Build() error {
|
|||||||
cfg.ScopeOpt = scopeOption
|
cfg.ScopeOpt = scopeOption
|
||||||
|
|
||||||
if cfg.Quiet {
|
if cfg.Quiet {
|
||||||
// quiet option trumps all other logging options
|
// TODO: this is bad: quiet option trumps all other logging options
|
||||||
|
// we should be able to quiet the consol logging and leave file logging alone...
|
||||||
|
// ... this will be an enhancement for later
|
||||||
cfg.Log.LevelOpt = zapcore.PanicLevel
|
cfg.Log.LevelOpt = zapcore.PanicLevel
|
||||||
} else {
|
} else {
|
||||||
if cfg.Log.Level != "" {
|
if cfg.Log.Level != "" {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user