Files
atom/services/command.go
yanghao05 7bbf6c1684 add service install
add command app boot
2023-05-12 11:45:18 +08:00

28 lines
428 B
Go

package services
import (
"github.com/rogeecn/atom/container"
"go.uber.org/dig"
)
type CommandService interface {
Register()
Execute() error
}
type Command struct {
dig.In
Commands []CommandService `group:"command_services"`
}
func ServeCommand(f func() error) error {
return container.Container.Invoke(func(command Command) error {
for _, cmd := range command.Commands {
cmd.Register()
}
return f()
})
}