MCPcopy
hub / github.com/cilium/cilium / writeTable

Function writeTable

tools/api-flaggen/main.go:63–83  ·  view source on GitHub ↗
(wr io.Writer, spec *loads.Document)

Source from the content-addressed store, hash-verified

61}
62
63func writeTable(wr io.Writer, spec *loads.Document) {
64 flagWidth := 20
65 colWidth := 80
66 tabWriter := tabwriter.NewWriter(wr, flagWidth, 0, 1, ' ', tabwriter.TabIndent)
67
68 fmt.Fprintln(tabWriter, "=========================\t====================")
69 fmt.Fprintln(tabWriter, "Flag Name \tDescription")
70 fmt.Fprintln(tabWriter, "=========================\t====================")
71
72 pathSet := api.NewPathSet(spec)
73 for _, k := range slices.Sorted(maps.Keys(pathSet)) {
74 desc := strings.TrimSuffix(pathSet[k].Description, "\n")
75 wrapped := wrap(desc, colWidth-flagWidth)
76 fmt.Fprintln(tabWriter, k+"\t"+wrapped[0])
77 for i := 1; i < len(wrapped); i++ {
78 fmt.Fprintln(tabWriter, " \t"+wrapped[i])
79 }
80 }
81 fmt.Fprintln(tabWriter, "=========================\t====================")
82 tabWriter.Flush()
83}
84
85func writeFlagPreamble(wr io.Writer, binary, flag string) {
86 fmt.Fprintf(wr, "The following API flags are compatible with the ``%s`` flag\n``%s``.\n\n",

Callers 1

printAPIFlagTablesFunction · 0.85

Calls 5

NewPathSetFunction · 0.92
NewWriterMethod · 0.80
KeysMethod · 0.80
wrapFunction · 0.70
FlushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…