diff --git a/cmd/helm/search.go b/cmd/helm/search.go index 845bfd0be..0feae1dac 100644 --- a/cmd/helm/search.go +++ b/cmd/helm/search.go @@ -1,12 +1,9 @@ /* Copyright 2016 The Kubernetes Authors All rights reserved. - Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +30,6 @@ import ( const searchDesc = ` Search reads through all of the repositories configured on the system, and looks for matches. - Repositories are managed with 'helm repo' commands. ` @@ -47,6 +43,7 @@ type searchCmd struct { versions bool regexp bool version string + colWidth uint } func newSearchCmd(out io.Writer) *cobra.Command { @@ -66,6 +63,7 @@ func newSearchCmd(out io.Writer) *cobra.Command { 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.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 } @@ -93,7 +91,7 @@ func (s *searchCmd) run(args []string) error { return err } - fmt.Fprintln(s.out, s.formatSearchResults(data)) + fmt.Fprintln(s.out, s.formatSearchResults(data, s.colWidth)) return nil } @@ -126,12 +124,12 @@ func (s *searchCmd) applyConstraint(res []*search.Result) ([]*search.Result, err 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 { return "No results found" } table := uitable.New() - table.MaxColWidth = 50 + table.MaxColWidth = colWidth table.AddRow("NAME", "CHART VERSION", "APP VERSION", "DESCRIPTION") for _, r := range res { table.AddRow(r.Name, r.Chart.Version, r.Chart.AppVersion, r.Chart.Description)