feat(comp): Add descriptions for revision comp

Ref: HIP 0008

When completing a revision, extra information will be shown for
shells that support completions (fish, zsh).  For example:

$ helm get manifest nginx --revision <TAB>
1  -- App: 1.19.1, Chart: nginx-6.0.2
2  -- App: v0.34.1, Chart: nginx-ingress-1.41.2

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
pull/9243/head
Marc Khouzam 4 years ago
parent 7dee24daae
commit 9856f056d4

@ -193,7 +193,9 @@ func compListRevisions(toComplete string, cfg *action.Configuration, releaseName
for _, release := range hist {
version := strconv.Itoa(release.Version)
if strings.HasPrefix(version, toComplete) {
revisions = append(revisions, version)
appVersion := fmt.Sprintf("App: %s", release.Chart.Metadata.AppVersion)
chartDesc := fmt.Sprintf("Chart: %s-%s", release.Chart.Metadata.Name, release.Chart.Metadata.Version)
revisions = append(revisions, fmt.Sprintf("%s\t%s, %s", version, appVersion, chartDesc))
}
}
return revisions, cobra.ShellCompDirectiveNoFileComp

@ -1,6 +1,6 @@
8
9
10
11
8 App: 1.0, Chart: foo-0.1.0-beta.1
9 App: 1.0, Chart: foo-0.1.0-beta.1
10 App: 1.0, Chart: foo-0.1.0-beta.1
11 App: 1.0, Chart: foo-0.1.0-beta.1
:4
Completion ended with directive: ShellCompDirectiveNoFileComp

Loading…
Cancel
Save