1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
completion.go 720 Bytes
一键复制 编辑 原始数据 按行查看 历史
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
func genCompletionCmd(name, version string, rootCmd *BeatsRootCmd) *cobra.Command {
completionCmd := cobra.Command{
Use: "completion SHELL",
Short: "Output shell completion code for the specified shell (bash only by the moment)",
// We don't want to expose this one in help:
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 1 {
fmt.Println("Expected one argument with the desired shell")
os.Exit(1)
}
switch args[0] {
case "bash":
rootCmd.GenBashCompletion(os.Stdout)
default:
fmt.Printf("Unknown shell %s, only bash is available\n", args[0])
}
},
}
return &completionCmd
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.0.0-beta2

搜索帮助