-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
78 lines (68 loc) · 1.8 KB
/
main.go
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"fmt"
"log"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
"github.com/dvordrova/gop/codegen"
"github.com/dvordrova/gop/tui/service"
)
func main() {
if len(os.Getenv("DEBUG")) > 0 {
f, err := tea.LogToFile("debug.log", "debug")
if err != nil {
fmt.Println("fatal:", err)
os.Exit(1)
}
defer f.Close()
}
var rootCmd = &cobra.Command{Use: "gop"}
var serviceCmd = &cobra.Command{
Use: "service",
Short: "Create/edit service",
Long: `This is a longer description of service.`,
RunE: func(cmd *cobra.Command, args []string) error {
p := tea.NewProgram(service.NewModel(), tea.WithAltScreen())
m, err := p.Run()
_ = m
return err
},
}
var projectCmd = &cobra.Command{
Use: "project",
Short: "[not implemented] create/edit project",
Long: `This is a longer description of project.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("not implemented yet")
},
}
var genCmd = &cobra.Command{
Use: "gen",
Short: "Generate service",
Long: `This is a longer description of gen.`,
RunE: func(cmd *cobra.Command, args []string) error {
return codegen.GenServiceStruct()
},
}
var startCmd = &cobra.Command{
Use: "start",
Short: "[not implemented] start service/project",
Long: `This is a longer description of start.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("not implemented yet")
},
}
var stopCmd = &cobra.Command{
Use: "stop",
Short: "[not implemented] stop running service/project",
Long: `This is a longer description of stop.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("not implemented yet")
},
}
rootCmd.AddCommand(serviceCmd, projectCmd, genCmd, startCmd, stopCmd)
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
}