feat(01-01): boot hello app and dispatch greeter:hello
- Add party plugin registry with Register-before-Boot activation - Add backpack, compass, bonfire, and pact capability interfaces - Add examples/hello with two compiled plugin modules
This commit is contained in:
43
examples/hello/plugins/greeter/plugin.go
Normal file
43
examples/hello/plugins/greeter/plugin.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package greeter
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.golem15.com/golem15/summercms/backpack"
|
||||
"git.golem15.com/golem15/summercms/bonfire"
|
||||
"git.golem15.com/golem15/summercms/party"
|
||||
)
|
||||
|
||||
// Plugin is the golem15.greeter plugin. It requires golem15.hello.
|
||||
type Plugin struct {
|
||||
app *backpack.App
|
||||
}
|
||||
|
||||
func (p *Plugin) ID() string { return "golem15.greeter" }
|
||||
func (p *Plugin) Requires() []string { return []string{"golem15.hello"} }
|
||||
|
||||
func (p *Plugin) Register(*backpack.App) error { return nil }
|
||||
|
||||
func (p *Plugin) Boot(app *backpack.App) error {
|
||||
p.app = app
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Plugin) Commands() []bonfire.Command {
|
||||
return []bonfire.Command{{
|
||||
Name: "greeter:hello",
|
||||
Description: "Print the configured application name",
|
||||
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
name := ""
|
||||
if p.app != nil && p.app.Config != nil {
|
||||
name = p.app.Config.String("app.name")
|
||||
}
|
||||
out.Println(name)
|
||||
return nil
|
||||
},
|
||||
}}
|
||||
}
|
||||
|
||||
func init() {
|
||||
party.Register(&Plugin{})
|
||||
}
|
||||
Reference in New Issue
Block a user