Skip to content

Commit

Permalink
Merge pull request #1206 from varunkashyap/improve-completion
Browse files Browse the repository at this point in the history
Improve error handling for `completion` command
  • Loading branch information
balopat authored Oct 26, 2018
2 parents 3ca1732 + d9b1441 commit 5d3c868
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/skaffold/app/cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package cmd

import (
"fmt"
"io"
"os"

Expand All @@ -25,8 +26,17 @@ import (

// completionCmd represents the completion command
var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generate shell completion scripts",
// Only bash is supported for now. However, having args after
// "completion" will help when supporting multiple shells
Use: "completion bash",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return fmt.Errorf("requires 1 arg, found %d", len(args))
}
return cobra.OnlyValidArgs(cmd, args)
},
ValidArgs: []string{"bash"},
Short: "Output command completion script for the bash shell",
Long: `To enable command completion run
eval "$(skaffold completion bash)"
Expand All @@ -40,6 +50,7 @@ eval "$(skaffold completion bash)"`,
},
}

// NewCmdCompletion returns the cobra command that outputs shell completion code
func NewCmdCompletion(out io.Writer) *cobra.Command {
return completionCmd
}

0 comments on commit 5d3c868

Please sign in to comment.