-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
64 lines (51 loc) · 1.4 KB
/
main.go
File metadata and controls
64 lines (51 loc) · 1.4 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
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
"github.com/olamilekan000/etcd-tui/internal/config"
"github.com/olamilekan000/etcd-tui/internal/tui/constants"
"github.com/olamilekan000/etcd-tui/internal/tui/model"
)
var (
configPath string
)
func main() {
rootCmd := &cobra.Command{
Use: "etcd-tui",
Short: "A terminal UI for etcd",
Long: `etcd-tui is a terminal user interface for interacting with etcd.
Configuration can be provided via:
- Config file: ~/.etcd-tui/config.json (or path specified with --config)
- Environment variables: ETCDCTL_ENDPOINTS, ETCDCTL_CACERT, etc.`,
Run: runTUI,
}
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "Path to config file (default: ~/.etcd-tui/config.json)")
versionCmd := &cobra.Command{
Use: "version",
Short: "Show version information",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(constants.Version)
},
}
rootCmd.AddCommand(versionCmd)
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}
func runTUI(cmd *cobra.Command, args []string) {
if configPath != "" {
config.SetConfigPath(configPath)
}
p := tea.NewProgram(
model.New(),
tea.WithAltScreen(),
tea.WithMouseCellMotion(),
)
if _, err := p.Run(); err != nil {
fmt.Printf("Error running program: %v\n", err)
os.Exit(1)
}
}