-
Notifications
You must be signed in to change notification settings - Fork 1
/
init_commands.go
194 lines (165 loc) · 5.53 KB
/
init_commands.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package main
import (
"fmt"
"github.com/ksckaan1/hexago/config"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/appcmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/doctorcmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/domaincmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/entrypointcmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/infracmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/initcmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/packagecmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/portcmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/rootcmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/runnercmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/servicecmd"
"github.com/ksckaan1/hexago/internal/domain/core/application/cli/treecmd"
"github.com/ksckaan1/hexago/internal/domain/core/service/project"
"github.com/ksckaan1/hexago/internal/pkg/tuilog"
)
func initCommands(projectService *project.Project, tl *tuilog.TUILog, cfg *config.Config) (*cli.CLI, error) {
// root
rootCmd, err := rootcmd.NewRootCommand()
if err != nil {
return nil, fmt.Errorf("rootcmd.NewRootCommand: %w", err)
}
// init
initCmd, err := initcmd.NewInitCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("initcmd.NewInitCommand: %w", err)
}
// domain
domainCmd, err := domaincmd.NewDomainCommand()
if err != nil {
return nil, fmt.Errorf("domaincmd.NewDomainCommand: %w", err)
}
domainLSCmd, err := domaincmd.NewDomainLSCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("domaincmd.NewDomainLSCommand: %w", err)
}
domainCreateCmd, err := domaincmd.NewDomainCreateCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("domaincmd.NewDomainCreateCommand: %w", err)
}
// service
serviceCmd, err := servicecmd.NewServiceCommand()
if err != nil {
return nil, fmt.Errorf("servicecmd.NewServiceCommand: %w", err)
}
serviceLSCmd, err := servicecmd.NewServiceLSCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("servicecmd.NewServiceLSCommand: %w", err)
}
serviceCreateCmd, err := servicecmd.NewServiceCreateCommand(projectService, cfg, tl)
if err != nil {
return nil, fmt.Errorf("servicecmd.NewServiceCreateCommand: %w", err)
}
// port
portCmd, err := portcmd.NewPortCommand()
if err != nil {
return nil, fmt.Errorf("portcmd.NewPortCommand: %w", err)
}
portLSCmd, err := portcmd.NewPortLSCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("portcmd.NewPortLSCommand: %w", err)
}
// app
appCmd, err := appcmd.NewAppCommand()
if err != nil {
return nil, fmt.Errorf("appcmd.NewAppCommand: %w", err)
}
appLSCmd, err := appcmd.NewAppLSCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("appcmd.NewAppLSCommand: %w", err)
}
appCreateCmd, err := appcmd.NewAppCreateCommand(projectService, cfg, tl)
if err != nil {
return nil, fmt.Errorf("appcmd.NewAppCreateCommand: %w", err)
}
// cmd
entryPointCmd, err := entrypointcmd.NewEntryPointCommand()
if err != nil {
return nil, fmt.Errorf("entrypointcmd.NewEntryPointCommand: %w", err)
}
entryPointLSCmd, err := entrypointcmd.NewEntryPointLSCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("entrypointcmd.NewEntryPointLSCommand: %w", err)
}
entryPointCreateCmd, err := entrypointcmd.NewEntryPointCreateCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("entrypointcmd.NewEntryPointCreateCommand: %w", err)
}
// infra
infraCmd, err := infracmd.NewInfraCommand()
if err != nil {
return nil, fmt.Errorf("infracmd.NewInfraCommand: %w", err)
}
infraLSCmd, err := infracmd.NewInfraLSCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("infracmd.NewInfraLSCommand: %w", err)
}
infraCreateCmd, err := infracmd.NewInfraCreateCommand(projectService, cfg, tl)
if err != nil {
return nil, fmt.Errorf("infracmd.NewInfraCreateCommand: %w", err)
}
// pkg
packageCmd, err := packagecmd.NewPackageCommand()
if err != nil {
return nil, fmt.Errorf("packagecmd.NewPackageCommand: %w", err)
}
packageLSCmd, err := packagecmd.NewPackageLSCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("packagecmd.NewPackageLSCommand: %w", err)
}
packageCreateCmd, err := packagecmd.NewPackageCreateCommand(projectService, cfg, tl)
if err != nil {
return nil, fmt.Errorf("packagecmd.NewPackageCreateCommand: %w", err)
}
// run
runnerCmd, err := runnercmd.NewRunnerCommand(projectService, cfg, tl)
if err != nil {
return nil, fmt.Errorf("runnercmd.NewRunnerCommand: %w", err)
}
// doctor
doctorCmd, err := doctorcmd.NewDoctorCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("doctorcmd.NewDoctorCommand: %w", err)
}
// tree
treeCmd, err := treecmd.NewTreeCommand(projectService, tl)
if err != nil {
return nil, fmt.Errorf("treecmd.NewTreeCommand: %w", err)
}
app, err := cli.New(
rootCmd,
initCmd,
domainCmd,
domainLSCmd,
domainCreateCmd,
serviceCmd,
serviceLSCmd,
serviceCreateCmd,
portCmd,
portLSCmd,
appCmd,
appLSCmd,
appCreateCmd,
entryPointCmd,
entryPointLSCmd,
entryPointCreateCmd,
infraCmd,
infraLSCmd,
infraCreateCmd,
packageCmd,
packageLSCmd,
packageCreateCmd,
runnerCmd,
doctorCmd,
treeCmd,
)
if err != nil {
return nil, fmt.Errorf("cli.New: %w", err)
}
return app, nil
}