-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
53 lines (44 loc) · 1.05 KB
/
main.go
File metadata and controls
53 lines (44 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"os"
"github.com/helmcode/kubectl-ai/cmd"
"github.com/spf13/cobra"
)
var (
version = "v0.1.2" // Overwritten at build time
)
func main() {
rootCmd := newRootCmd()
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}
func newRootCmd() *cobra.Command {
rootCmd := &cobra.Command{
Use: "kubectl-ai",
Short: "AI-powered Kubernetes debugging",
Long: `kubectl-ai uses AI to analyze Kubernetes resources and help identify
configuration issues, performance problems, and provide recommendations.`,
SilenceUsage: true,
}
// Disable automatic 'completion' command added by cobra
rootCmd.CompletionOptions.DisableDefaultCmd = true
// Add subcommands
rootCmd.AddCommand(
cmd.NewDebugCmd(),
cmd.NewMetricsCmd(),
newVersionCmd(),
)
return rootCmd
}
func newVersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Print the version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("kubectl-ai version %s\n", version)
},
}
}