(rsp *server.AddHelpPageResponse)
| 29 | ) |
| 30 | |
| 31 | func 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 | |
| 62 | func apiBashCleanCompletionsMain(appBase string) { |
| 63 | lines, err := shells.BashRemoveCompletions(appBase, os.Stdin) |
no test coverage detected