MCPcopy Create free account
hub / github.com/celer-pkg/celer / doSearch

Method doSearch

cmds/cmd_search.go:55–82  ·  view source on GitHub ↗
(pattern string)

Source from the content-addressed store, hash-verified

53}
54
55func (s *searchCmd) doSearch(pattern string) error {
56 // Initialize celer configuration.
57 if err := s.celer.Init(); err != nil {
58 return color.PrintError(err, "Failed to initialize celer.")
59 }
60
61 // Perform search.
62 libraries, err := s.search(pattern)
63 if err != nil {
64 return color.PrintError(err, "Failed to search available ports.")
65 }
66
67 // Display results.
68 title := fmt.Sprintf("search results that match pattern '%s':", pattern)
69 color.Println(color.Title, title)
70 color.Println(color.Line, strings.Repeat("-", len(title)))
71 if len(libraries) > 0 {
72 for _, lib := range libraries {
73 color.Println(color.Hint, lib)
74 }
75 color.Println(color.Line, strings.Repeat("-", len(title)))
76 color.Printf(color.Summary, "total: %d port(s)\n", len(libraries))
77 } else {
78 color.Println(color.Error, "no matched port found.")
79 }
80
81 return nil
82}
83
84func (s *searchCmd) search(pattern string) ([]string, error) {
85 var results []string

Callers 2

CommandMethod · 0.95

Calls 6

searchMethod · 0.95
PrintErrorFunction · 0.92
PrintlnFunction · 0.92
PrintfFunction · 0.92
SprintfMethod · 0.80
InitMethod · 0.65

Tested by 1