1
0
mirror of synced 2026-02-07 03:05:56 +00:00

Add bash completion cmd

This commit is contained in:
stefanprodan
2020-05-01 19:46:54 +03:00
parent 155cc66db9
commit afcb41c59b
33 changed files with 116 additions and 43 deletions

28
cmd/tk/completion.go Normal file
View File

@@ -0,0 +1,28 @@
package main
import (
"os"
"github.com/spf13/cobra"
)
var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generates bash completion scripts",
Example: `To load completion run
. <(tk completion)
To configure your bash shell to load completions for each session add to your bashrc
# ~/.bashrc or ~/.profile
. <(tk completion)
`,
Run: func(cmd *cobra.Command, args []string) {
rootCmd.GenBashCompletion(os.Stdout)
},
}
func init() {
rootCmd.AddCommand(completionCmd)
}

View File

@@ -47,15 +47,11 @@ func deleteKsCmdRun(cmd *cobra.Command, args []string) error {
}
if !deleteSilent {
warning := "This action will remove the Kubernetes objects previously applied by this kustomization. "
if kustomization.Spec.Suspend {
warning = ""
if !kustomization.Spec.Suspend {
logWaiting("This action will remove the Kubernetes objects previously applied by the %s kustomization!", name)
}
prompt := promptui.Prompt{
Label: fmt.Sprintf(
"%sAre you sure you want to delete the %s kustomization from the %s namespace",
warning, name, namespace,
),
Label: "Are you sure you want to delete this kustomization",
IsConfirm: true,
}
if _, err := prompt.Run(); err != nil {

View File

@@ -47,9 +47,7 @@ func deleteSourceGitCmdRun(cmd *cobra.Command, args []string) error {
if !deleteSilent {
prompt := promptui.Prompt{
Label: fmt.Sprintf(
"Are you sure you want to delete the %s source from the %s namespace", name, namespace,
),
Label: "Are you sure you want to delete this source",
IsConfirm: true,
}
if _, err := prompt.Run(); err != nil {