Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
56 lines
1.3 KiB
Text
56 lines
1.3 KiB
Text
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
hplugin "github.com/hashicorp/go-plugin"
|
|
|
|
|
|
"github.com/ignite/cli/v29/ignite/services/plugin"
|
|
"<%= AppName %>/cmd"
|
|
)
|
|
|
|
type app struct{}
|
|
|
|
func (app) Manifest(_ context.Context) (*plugin.Manifest, error) {
|
|
return &plugin.Manifest{
|
|
Name: "<%= Name %>",<%= if (SharedHost) { %>
|
|
SharedHost: true,<% } %>
|
|
Commands: cmd.GetCommands(),
|
|
}, nil
|
|
}
|
|
|
|
func (app) Execute(ctx context.Context, c *plugin.ExecutedCommand, _ plugin.ClientAPI) error {
|
|
// Remove the first two elements "ignite" and "<%= Name %>" from OsArgs.
|
|
args := c.OsArgs[2:]
|
|
|
|
switch args[0] {
|
|
case "hello":
|
|
return cmd.ExecuteHello(ctx, c)
|
|
default:
|
|
return fmt.Errorf("unknown command: %s", c.Path)
|
|
}
|
|
}
|
|
|
|
func (app) ExecuteHookPre(_ context.Context, _ *plugin.ExecutedHook, _ plugin.ClientAPI) error {
|
|
return nil
|
|
}
|
|
|
|
func (app) ExecuteHookPost(_ context.Context, _ *plugin.ExecutedHook, _ plugin.ClientAPI) error {
|
|
return nil
|
|
}
|
|
|
|
func (app) ExecuteHookCleanUp(_ context.Context, _ *plugin.ExecutedHook, _ plugin.ClientAPI) error {
|
|
return nil
|
|
}
|
|
|
|
func main() {
|
|
hplugin.Serve(&hplugin.ServeConfig{
|
|
HandshakeConfig: plugin.HandshakeConfig(),
|
|
Plugins: map[string]hplugin.Plugin{
|
|
"<%= Name %>": plugin.NewGRPC(&app{}),
|
|
},
|
|
GRPCServer: hplugin.DefaultGRPCServer,
|
|
})
|
|
}
|