diff options
Diffstat (limited to 'cmd/krino/check.go')
| -rw-r--r-- | cmd/krino/check.go | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/cmd/krino/check.go b/cmd/krino/check.go index fcd507d..1820bbe 100644 --- a/cmd/krino/check.go +++ b/cmd/krino/check.go @@ -5,40 +5,52 @@ package main import ( "fmt" "io" - "os" - "krino/internal/config" + "krino/internal/engine" "krino/internal/xdg" ) func init() { commands["check"] = cmdCheck } -// cmdCheck validates the configuration and lists each directory's rules. +// cmdCheck validates the configuration and lists each directory's rules, +// its current state, and the extractors available for content tests. func cmdCheck(g *globals, args []string, stdout, stderr io.Writer) int { fs := flagSet("check", g) if code, ok := parse(fs, args, stdout, stderr); !ok { return code } - cfg, errs := config.Load(mainFile(g), fs.Args()...) + e, errs := engine.Load(mainFile(g), fs.Args()...) if len(errs) > 0 { printDiags(stderr, errs) return 2 } - fmt.Fprintf(stdout, "config: %s\n", xdg.Abbrev(cfg.Main.File)) - if len(cfg.Dirs) == 0 { + r := e.Check() + + fmt.Fprintf(stdout, "config: %s\n", xdg.Abbrev(r.MainFile)) + fmt.Fprintf(stdout, "log: %s\n", xdg.Abbrev(r.LogFile)) + if len(r.Dirs) == 0 { fmt.Fprintln(stdout, "no directories included; add one with: krino new NAME PATH") } - for _, d := range cfg.Dirs { - fmt.Fprintf(stdout, "\n%s %s\n", d.Name, xdg.Abbrev(d.Path)) - if fi, err := os.Stat(d.Path); err != nil || !fi.IsDir() { - fmt.Fprintf(stdout, " warning: %s is not a directory right now; it will be skipped\n", xdg.Abbrev(d.Path)) + for _, dr := range r.Dirs { + fmt.Fprintf(stdout, "\n%s %s\n", dr.Dir.Name, xdg.Abbrev(dr.Dir.Root)) + if dr.Missing { + fmt.Fprintf(stdout, " warning: %s is not a directory right now; it will be skipped\n", xdg.Abbrev(dr.Dir.Root)) } - if len(d.Rules) == 0 { + if len(dr.Dir.Rules) == 0 { fmt.Fprintln(stdout, " no rules yet") } - for i, r := range d.Rules { - fmt.Fprintf(stdout, " %2d %-16s %s\n", i+1, r.Name, describeActions(r)) + for i, rule := range dr.Dir.Rules { + fmt.Fprintf(stdout, " %2d %-16s %s\n", i+1, rule.Name, describeActions(rule.Conf)) + } + } + + fmt.Fprintln(stdout, "\nextractors:") + for _, tool := range r.Tools { + path := "not installed" + if tool.Path != "" { + path = xdg.Abbrev(tool.Path) } + fmt.Fprintf(stdout, " %-9s %s\n", tool.Name, path) } return 0 } |
