package main import ( "encoding/json" "fmt" "ollie/tools/codeintel/internal/codeintel" "os" "path/filepath" ) func main() { type arguments struct { Path string `json:"path"` Language string `json:"language"` Query string `json:"query"` } var a arguments if err := json.NewDecoder(os.Stdin).Decode(&a); err != nil { fail(err) } p, err := filepath.Abs(a.Path) if err != nil { fail(err) } cs, err := codeintel.Query(p, a.Language, a.Query) if err != nil { fail(err) } for _, c := range cs { fmt.Printf("%s:%d: %s = %s\n", c.Name, c.Line, c.Name, c.Text) } } func fail(e error) { fmt.Fprintln(os.Stderr, "error:", e); os.Exit(1) }