func NewCmdCompletion(out io.Writer, rootCommand *cobra.Command) *cobra.Command {
	var o completionOptions
	cmd := &cobra.Command{
		Use:   "completion <shell>",
		Short: "Generate completion scripts for your shell",
		Long: `Write bash, powershell or zsh shell completion code for kyml to stdout.
bash: Ensure you have bash completions installed and enabled. Then output to a file and load it from your .bash_profile.
powershell: Ensure you have a PowerShell profile. Then output to a file and source it from the file provided by "$profile".
zsh: Output to a file in a directory referenced by the $fpath shell variable.`,
		RunE: func(cmd *cobra.Command, args []string) error {
			err := o.Validate(args)
			if err != nil {
				return err
			}
			return o.Run(out, rootCommand)
		},
		ValidArgs: []string{"bash", "powershell", "zsh"},
	}
	return cmd
}
NewCmdCompletion creates a new completion command.
package completion
import (
	"fmt"
	"io"
	"github.com/spf13/cobra"
)
type completionOptions struct {
	shell string
}