MCPcopy
hub / github.com/perkeep/perkeep / formattedSearchHelp

Function formattedSearchHelp

cmd/pk/searchdoc.go:56–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54}
55
56func formattedSearchHelp() {
57 s := search.SearchHelp()
58 type help struct{ Name, Description string }
59 h := []help{}
60 err := json.Unmarshal([]byte(s), &h)
61 if err != nil {
62 cmdmain.Errorf("%v", err)
63 os.Exit(1)
64 }
65
66 w := new(tabwriter.Writer)
67 w.Init(cmdmain.Stdout, 0, 8, 0, '\t', 0)
68 fmt.Fprintln(w, "Predicates for search expressions")
69 fmt.Fprintln(w)
70 fmt.Fprintln(w, "Predicate\tDescription")
71 fmt.Fprintln(w)
72 for _, predicate := range h {
73 desc := strings.Split(predicate.Description, "\n")
74 for i, d := range desc {
75 if i == 0 {
76 fmt.Fprintf(w, "%s\t%s\n", predicate.Name, d)
77 } else {
78 fmt.Fprintf(w, "\t%s\n", d)
79 }
80 }
81 }
82 w.Flush()
83}

Callers 1

RunCommandMethod · 0.85

Calls 3

SearchHelpFunction · 0.92
ErrorfFunction · 0.92
FlushMethod · 0.45

Tested by

no test coverage detected