MCPcopy Create free account
hub / github.com/dim-an/cod / summarizeLearning

Function summarizeLearning

commands.go:31–60  ·  view source on GitHub ↗
(rsp *server.AddHelpPageResponse)

Source from the content-addressed store, hash-verified

29)
30
31func summarizeLearning(rsp *server.AddHelpPageResponse) (err error) {
32 var msg string
33 if rsp.Status == datastore.AddHelpPageStatusNew {
34 examples := ""
35
36 for i := range rsp.HelpPage.Completions {
37 if i > 0 {
38 examples += " "
39 }
40 cur := fmt.Sprintf("%q", rsp.HelpPage.Completions[i].Flag)
41 if i == 0 || len(examples+cur) < 35 {
42 examples += cur
43 } else {
44 examples += fmt.Sprintf("and %v more", len(rsp.HelpPage.Completions)-i)
45 break
46 }
47 }
48
49 msg = fmt.Sprintf("cod: learned completions: %s\n", examples)
50 } else {
51 if rsp.Status != datastore.AddHelpPageStatusUpdated {
52 panic(fmt.Errorf("unexpected status: %v", rsp.Status))
53 }
54 msg = fmt.Sprintf("cod: updated completions\n")
55 }
56
57 ui := NewUI()
58 _, err = fmt.Print(ui.Styled("green", msg))
59 return
60}
61
62func apiBashCleanCompletionsMain(appBase string) {
63 lines, err := shells.BashRemoveCompletions(appBase, os.Stdin)

Callers 2

apiPostexecMainFunction · 0.85
learnMainFunction · 0.85

Calls 2

StyledMethod · 0.95
NewUIFunction · 0.85

Tested by

no test coverage detected