* feat(windows): 增加原生服务安装包 * fix(windows): 收紧服务安装与升级流程 * fix(windows): 固定服务安装路径与语言资源 * fix(windows): 等待安装器进程完成 * fix(windows): 清理首次安装失败残留
24 lines
616 B
Go
24 lines
616 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type serviceCommand struct {
|
|
action string
|
|
}
|
|
|
|
func parseServiceCommand(args []string) (serviceCommand, error) {
|
|
if len(args) == 0 {
|
|
return serviceCommand{}, fmt.Errorf("service action is required")
|
|
}
|
|
command := serviceCommand{action: args[0]}
|
|
switch command.action {
|
|
case "install", "run", "start", "stop", "restart", "status", "uninstall":
|
|
if len(args) != 1 {
|
|
return serviceCommand{}, fmt.Errorf("service %s does not accept options", command.action)
|
|
}
|
|
return command, nil
|
|
default:
|
|
return serviceCommand{}, fmt.Errorf("unknown service action %q", command.action)
|
|
}
|
|
}
|