with handling for do

This commit is contained in:
2022-11-05 23:05:41 +01:00
parent fd826827f6
commit 52f44f7c2e
8 changed files with 77 additions and 15 deletions

View File

@@ -10,6 +10,29 @@ type PluginClient struct {
client *rpc.Client
}
type DoRequest struct {
CommandName string `json:"commandName"`
Args map[string]string `json:"args"`
}
// Do implements Plugin
func (pc *PluginClient) Do(ctx context.Context, commandName string, args map[string]string) error {
req := &DoRequest{
CommandName: commandName,
Args: args,
}
doReq, err := json.Marshal(req)
if err != nil {
return err
}
err = pc.client.Call("Plugin.Do", doReq, new(any))
if err != nil {
return err
}
return nil
}
var _ Plugin = &PluginClient{}
func (pc *PluginClient) About(ctx context.Context) (*About, error) {