Skip to content

Commit

Permalink
update completionExample
Browse files Browse the repository at this point in the history
Signed-off-by: zhzhuang-zju <m17799853869@163.com>
  • Loading branch information
zhzhuang-zju committed Sep 13, 2024
1 parent aaa0233 commit 6eb8eb4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/karmadactl/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,15 @@ var (
completionExample = templates.Examples(i18n.T(`
# Installing bash completion on Linux
## If bash-completion is not installed on Linux, install the 'bash-completion' package
1. apt-get install bash-completion
2. source /usr/share/bash-completion/bash_completion
## via your distribution's package manager.
## Load the %[1]s completion code for bash into the current shell
source <(%[1]s completion bash)
## Write bash completion code to a file and source it from .bash_profile
%[1]s completion bash > ~/.kube/completion.bash.inc
printf "
# %[1]s shell completion
source '$HOME/.kube/completion.bash.inc'
" >> $HOME/.bash_profile
source $HOME/.bash_profile
## Or, write bash completion code to a file and source it from .bash_profile
1. %[1]s completion bash > ~/.kube/completion.bash.inc
2. echo "source '$HOME/.kube/completion.bash.inc'" >> $HOME/.bash_profile
3. source $HOME/.bash_profile
# Load the %[1]s completion code for zsh[1] into the current shell
source <(%[1]s completion zsh)
Expand Down
5 changes: 5 additions & 0 deletions pkg/karmadactl/cordon/cordon.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ const (
// NewCmdCordon defines the `cordon` command that mark cluster as unschedulable.
func NewCmdCordon(f util.Factory, parentCommand string) *cobra.Command {
opts := CommandCordonOption{}

validArgs := []string{"cluster"}

cmd := &cobra.Command{
Use: "cordon CLUSTER",
Short: "Mark cluster as unschedulable",
Long: cordonLong,
Example: fmt.Sprintf(cordonExample, parentCommand),
SilenceUsage: true,
DisableFlagsInUseLine: true,
ValidArgsFunction: utilcomp.SpecifiedResourceTypeAndNameCompletionFunc(f, validArgs),
RunE: func(_ *cobra.Command, args []string) error {
if err := opts.Complete(args); err != nil {
return err
Expand Down Expand Up @@ -96,6 +100,7 @@ func NewCmdUncordon(f util.Factory, parentCommand string) *cobra.Command {
opts := CommandCordonOption{}

validArgs := []string{"cluster"}

cmd := &cobra.Command{
Use: "uncordon CLUSTER",
Short: "Mark cluster as schedulable",
Expand Down

0 comments on commit 6eb8eb4

Please sign in to comment.