diff --git a/commands/tui.go b/commands/tui.go index 7250b5ed..94347c6a 100644 --- a/commands/tui.go +++ b/commands/tui.go @@ -32,10 +32,11 @@ import ( // TuiCmd is Subcommand of host discovery mode type TuiCmd struct { - lang string - debugSQL bool - debug bool - logDir string + lang string + debugSQL bool + debug bool + configPath string + logDir string resultsDir string refreshCve bool @@ -56,6 +57,7 @@ func (*TuiCmd) Synopsis() string { return "Run Tui view to anayze vulnerabilites func (*TuiCmd) Usage() string { return `tui: tui + [-config=/path/to/config.toml] [-cvedb-type=sqlite3|mysql|postgres] [-cvedb-path=/path/to/cve.sqlite3] [-cvedb-url=http://127.0.0.1:1323 or DB connection string] @@ -82,6 +84,9 @@ func (p *TuiCmd) SetFlags(f *flag.FlagSet) { defaultResultsDir := filepath.Join(wd, "results") f.StringVar(&p.resultsDir, "results-dir", defaultResultsDir, "/path/to/results") + defaultConfPath := filepath.Join(wd, "config.toml") + f.StringVar(&p.configPath, "config", defaultConfPath, "/path/to/toml") + f.BoolVar( &p.refreshCve, "refresh-cve", @@ -125,6 +130,11 @@ func (p *TuiCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) s util.Log = util.NewCustomLogger(c.ServerInfo{}) log := util.Log + if err := c.Load(p.configPath, ""); err != nil { + util.Log.Errorf("Error loading %s, %s", p.configPath, err) + return subcommands.ExitUsageError + } + c.Conf.ResultsDir = p.resultsDir c.Conf.CveDBType = p.cvedbtype c.Conf.CveDBPath = p.cvedbpath