char/pkg/register/plugin.go

30 lines
709 B
Go
Raw Normal View History

2022-11-01 14:26:54 +01:00
package register
2022-11-01 21:15:32 +01:00
import "context"
2022-11-02 22:10:15 +01:00
type AboutCommand struct {
Name string `json:"name" yaml:"name"`
Args []string `json:"args" yaml:"args"`
Required []string `json:"required" yaml:"required"`
}
2022-11-01 21:15:32 +01:00
type About struct {
2022-11-02 22:10:15 +01:00
Name string `json:"name"`
Version string `json:"version"`
About string `json:"about"`
Vars []string `json:"vars"`
Commands []*AboutCommand `json:"commands"`
2022-11-01 21:15:32 +01:00
}
2022-11-05 23:19:09 +01:00
type DoCommand struct {
CommandName string `json:"commandName"`
Args map[string]string `json:"args"`
}
2022-11-01 14:26:54 +01:00
type Plugin interface {
2022-11-01 21:15:32 +01:00
About(ctx context.Context) (*About, error)
2022-11-05 23:19:09 +01:00
Do(ctx context.Context, cmd *DoCommand) error
2022-11-01 14:26:54 +01:00
}
2022-11-02 20:30:44 +01:00
const PluginKey = "plugin"