mirror of https://github.com/helm/helm.git
feat(comp): Support --generate-name in completion
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
This commit is contained in:
parent
62c9c34d49
commit
de1ca6784a
|
@ -125,7 +125,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
|
||||
// Function providing dynamic auto-completion
|
||||
completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) {
|
||||
return compInstall(args, toComplete)
|
||||
return compInstall(args, toComplete, client)
|
||||
})
|
||||
|
||||
addInstallFlags(cmd.Flags(), client, valueOpts)
|
||||
|
@ -233,8 +233,12 @@ func isChartInstallable(ch *chart.Chart) (bool, error) {
|
|||
}
|
||||
|
||||
// Provide dynamic auto-completion for the install and template commands
|
||||
func compInstall(args []string, toComplete string) ([]string, completion.BashCompDirective) {
|
||||
if len(args) == 1 {
|
||||
func compInstall(args []string, toComplete string, client *action.Install) ([]string, completion.BashCompDirective) {
|
||||
requiredArgs := 1
|
||||
if client.GenerateName {
|
||||
requiredArgs = 0
|
||||
}
|
||||
if len(args) == requiredArgs {
|
||||
return compListCharts(toComplete, true)
|
||||
}
|
||||
return nil, completion.BashCompDirectiveNoFileComp
|
||||
|
|
|
@ -126,7 +126,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|||
|
||||
// Function providing dynamic auto-completion
|
||||
completion.RegisterValidArgsFunc(cmd, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) {
|
||||
return compInstall(args, toComplete)
|
||||
return compInstall(args, toComplete, client)
|
||||
})
|
||||
|
||||
f := cmd.Flags()
|
||||
|
|
Loading…
Reference in New Issue