MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / Run

Method Run

internal/apps/app_cmd.go:129–177  ·  view source on GitHub ↗

Run 运行

(main func())

Source from the content-addressed store, hash-verified

127
128// Run 运行
129func (this *AppCmd) Run(main func()) {
130 // 获取参数
131 var args = os.Args[1:]
132 if len(args) > 0 {
133 var mainArg = args[0]
134 this.callDirective(mainArg + ":before")
135
136 switch mainArg {
137 case "-v", "version", "-version", "--version":
138 this.runVersion()
139 return
140 case "?", "help", "-help", "h", "-h":
141 this.runHelp()
142 return
143 case "start":
144 this.runStart()
145 return
146 case "stop":
147 this.runStop()
148 return
149 case "restart":
150 this.runRestart()
151 return
152 case "status":
153 this.runStatus()
154 return
155 }
156
157 // 查找指令
158 for _, directive := range this.directives {
159 if directive.Arg == mainArg {
160 directive.Callback()
161 return
162 }
163 }
164
165 fmt.Println("unknown command '" + mainArg + "'")
166
167 return
168 }
169
170 // 日志
171 var writer = new(LogWriter)
172 writer.Init()
173 logs.SetWriter(writer)
174
175 // 运行主函数
176 main()
177}
178
179// 版本号
180func (this *AppCmd) runVersion() {

Callers 1

runStopMethod · 0.45

Calls 9

callDirectiveMethod · 0.95
runVersionMethod · 0.95
runHelpMethod · 0.95
runStartMethod · 0.95
runStopMethod · 0.95
runRestartMethod · 0.95
runStatusMethod · 0.95
InitMethod · 0.65
mainFunction · 0.50

Tested by

no test coverage detected