mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 15:16:33 -08:00
* fix(github): return db size * fix(github_mock): add size * feat(indicator): add progress bar * refactor(config): remove global Quiet * fix(db): take progress bar as an argument * fix(progress): inject progress bar
51 lines
990 B
Go
51 lines
990 B
Go
package config
|
|
|
|
import (
|
|
"github.com/urfave/cli"
|
|
"golang.org/x/xerrors"
|
|
)
|
|
|
|
type Config struct {
|
|
context *cli.Context
|
|
|
|
Quiet bool
|
|
Debug bool
|
|
CacheDir string
|
|
Reset bool
|
|
DownloadDBOnly bool
|
|
SkipUpdate bool
|
|
|
|
Listen string
|
|
Token string
|
|
|
|
// these variables are generated by Init()
|
|
AppVersion string
|
|
}
|
|
|
|
func New(c *cli.Context) Config {
|
|
debug := c.Bool("debug")
|
|
quiet := c.Bool("quiet")
|
|
return Config{
|
|
context: c,
|
|
|
|
Quiet: quiet,
|
|
Debug: debug,
|
|
CacheDir: c.String("cache-dir"),
|
|
Reset: c.Bool("reset"),
|
|
DownloadDBOnly: c.Bool("download-db-only"),
|
|
SkipUpdate: c.Bool("skip-update"),
|
|
Listen: c.String("listen"),
|
|
Token: c.String("token"),
|
|
}
|
|
}
|
|
|
|
func (c *Config) Init() (err error) {
|
|
if c.SkipUpdate && c.DownloadDBOnly {
|
|
return xerrors.New("The --skip-update and --download-db-only option can not be specified both")
|
|
}
|
|
|
|
c.AppVersion = c.context.App.Version
|
|
|
|
return nil
|
|
}
|