|
|
@ -47,6 +47,7 @@ type searchCmd struct {
|
|
|
|
versions bool
|
|
|
|
versions bool
|
|
|
|
regexp bool
|
|
|
|
regexp bool
|
|
|
|
version string
|
|
|
|
version string
|
|
|
|
|
|
|
|
colWidth uint
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func newSearchCmd(out io.Writer) *cobra.Command {
|
|
|
|
func newSearchCmd(out io.Writer) *cobra.Command {
|
|
|
@ -66,6 +67,7 @@ func newSearchCmd(out io.Writer) *cobra.Command {
|
|
|
|
f.BoolVarP(&sc.regexp, "regexp", "r", false, "use regular expressions for searching")
|
|
|
|
f.BoolVarP(&sc.regexp, "regexp", "r", false, "use regular expressions for searching")
|
|
|
|
f.BoolVarP(&sc.versions, "versions", "l", false, "show the long listing, with each version of each chart on its own line")
|
|
|
|
f.BoolVarP(&sc.versions, "versions", "l", false, "show the long listing, with each version of each chart on its own line")
|
|
|
|
f.StringVarP(&sc.version, "version", "v", "", "search using semantic versioning constraints")
|
|
|
|
f.StringVarP(&sc.version, "version", "v", "", "search using semantic versioning constraints")
|
|
|
|
|
|
|
|
f.UintVar(&sc.colWidth, "col-width", 60, "specifies the max column width of output")
|
|
|
|
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -93,7 +95,7 @@ func (s *searchCmd) run(args []string) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintln(s.out, s.formatSearchResults(data))
|
|
|
|
fmt.Fprintln(s.out, s.formatSearchResults(data, s.colWidth))
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -126,12 +128,12 @@ func (s *searchCmd) applyConstraint(res []*search.Result) ([]*search.Result, err
|
|
|
|
return data, nil
|
|
|
|
return data, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *searchCmd) formatSearchResults(res []*search.Result) string {
|
|
|
|
func (s *searchCmd) formatSearchResults(res []*search.Result, colWidth uint) string {
|
|
|
|
if len(res) == 0 {
|
|
|
|
if len(res) == 0 {
|
|
|
|
return "No results found"
|
|
|
|
return "No results found"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
table := uitable.New()
|
|
|
|
table := uitable.New()
|
|
|
|
table.MaxColWidth = 50
|
|
|
|
table.MaxColWidth = colWidth
|
|
|
|
table.AddRow("NAME", "CHART VERSION", "APP VERSION", "DESCRIPTION")
|
|
|
|
table.AddRow("NAME", "CHART VERSION", "APP VERSION", "DESCRIPTION")
|
|
|
|
for _, r := range res {
|
|
|
|
for _, r := range res {
|
|
|
|
table.AddRow(r.Name, r.Chart.Version, r.Chart.AppVersion, r.Chart.Description)
|
|
|
|
table.AddRow(r.Name, r.Chart.Version, r.Chart.AppVersion, r.Chart.Description)
|
|
|
|