sdk

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 10 Imported by: 0

README

MOPS SDK

The MOPS SDK provides a simple and powerful way to create plugins for the MOPS (Micro Operations System).

Overview

MOPS is a terminal-based operations management system that supports extensible plugins. This SDK allows you to create plugins that can:

  • Provide dynamic menu entries
  • Execute custom actions
  • Add interactive streaming functions
  • Extend CLI commands
  • Add menu entries to existing menus

Installation

go get github.com/totmicro/mops-sdk

Quick Start

Here's a simple "Hello World" plugin:

package main

import (
    "fmt"
    "github.com/totmicro/mops-sdk"
)

func main() {
    plugin := sdk.NewPluginBuilder("hello-world", "1.0.0", "A simple hello world plugin").
        SetAuthor("Your Name").
        SetLicense("MIT").
        WithSimpleExecutor("hello", func(entry sdk.MenuEntry, input string) sdk.ActionResult {
            name := input
            if name == "" {
                name = "World"
            }
            return sdk.ActionResult{
                Success:    true,
                Output:     fmt.Sprintf("Hello, %s!", name),
                ShowOutput: true,
            }
        }).
        Build()

    sdk.Main(plugin)
}

Plugin Builder API

Creating a Plugin
plugin := sdk.NewPluginBuilder("plugin-name", "1.0.0", "Plugin description")
Setting Metadata
plugin.SetAuthor("Author Name").
       SetLicense("MIT").
       SetHomepage("https://github.com/user/plugin").
       SetMopsVersions("1.0.0", "2.0.0").
       AddTag("utility").
       AddDependency("some-other-plugin")
Adding Functionality
Simple Action Executor
plugin.WithSimpleExecutor("my-action", func(entry sdk.MenuEntry, input string) sdk.ActionResult {
    return sdk.ActionResult{
        Success:    true,
        Output:     "Action executed successfully",
        ShowOutput: true,
    }
})
Dynamic Provider
plugin.WithSimpleProvider("my-provider", "Provides dynamic entries", func(param string) ([]sdk.MenuEntry, error) {
    return []sdk.MenuEntry{
        {
            Key:    "1",
            Label:  "Option 1",
            Action: "my-action",
        },
        {
            Key:    "2", 
            Label:  "Option 2",
            Action: "my-action",
        },
    }, nil
})
Interactive Function
plugin.WithInteractiveFunction("my-interactive", func(ctx context.Context, outputChan chan<- string, inputChan <-chan string, params map[string]interface{}) error {
    outputChan <- "Enter your name:"
    
    select {
    case name := <-inputChan:
        outputChan <- fmt.Sprintf("Hello, %s!", name)
    case <-ctx.Done():
        return ctx.Err()
    }
    
    return nil
})
CLI Command
plugin.WithCLICommand("hello", "Print a greeting", func(args []string) error {
    name := "World"
    if len(args) > 0 {
        name = args[0]
    }
    fmt.Printf("Hello, %s!\n", name)
    return nil
})

Plugin Structure

A typical plugin project structure:

my-plugin/
├── main.go           # Plugin entry point
├── go.mod           # Go module file
├── plugin.yaml      # Plugin metadata (optional)
├── Makefile         # Build configuration
├── README.md        # Plugin documentation
└── internal/        # Internal plugin code
    ├── core/        # Core plugin logic
    ├── cli/         # CLI command handlers
    └── ui/          # UI-related code

Building and Distribution

Local Development
go build -o my-plugin .
mkdir -p ~/.mops/plugins
cp my-plugin ~/.mops/plugins/
Multi-platform Build
# Linux AMD64
GOOS=linux GOARCH=amd64 go build -o my-plugin-linux-amd64 .

# macOS AMD64  
GOOS=darwin GOARCH=amd64 go build -o my-plugin-darwin-amd64 .

# Windows AMD64
GOOS=windows GOARCH=amd64 go build -o my-plugin-windows-amd64.exe .

Plugin Metadata (plugin.yaml)

name: my-plugin
version: 1.0.0
description: "My awesome plugin"
author: "Your Name"
license: "MIT"
homepage: "https://github.com/user/my-plugin"
tags:
  - "utility"
  - "example"

# MOPS version compatibility
mops_version:
  min_version: "1.0.0"
  max_version: "2.0.0"

# Build targets
build_targets:
  - os: linux
    arch: amd64
    output: my-plugin-linux-amd64
  - os: darwin
    arch: amd64
    output: my-plugin-darwin-amd64
  - os: windows
    arch: amd64
    output: my-plugin-windows-amd64.exe

# Default configuration
default_config:
  enabled: true
  timeout: 30

# CLI commands
cli_commands:
  - name: hello
    description: "Print a greeting"
    usage: "mops plugin my-plugin hello [name]"
    examples:
      - "mops plugin my-plugin hello"
      - "mops plugin my-plugin hello World"

Examples

Check the examples/ directory for complete plugin examples:

  • hello-world/ - Basic plugin with action executor
  • file-manager/ - Plugin with dynamic providers
  • interactive-demo/ - Plugin with interactive functions
  • cli-tools/ - Plugin with CLI commands

API Reference

Core Types
  • Plugin - Main plugin interface
  • PluginInfo - Plugin metadata
  • ActionResult - Result of action execution
  • MenuEntry - Menu entry definition
  • DynamicProvider - Interface for dynamic menu providers
  • ActionExecutor - Interface for action executors
  • InteractiveGoFunction - Interactive function type
Plugin Builder Methods
  • NewPluginBuilder(name, version, description) - Create new builder
  • SetAuthor(author) - Set plugin author
  • SetLicense(license) - Set plugin license
  • SetHomepage(url) - Set plugin homepage
  • AddTag(tag) - Add plugin tag
  • WithSimpleExecutor(type, handler) - Add action executor
  • WithSimpleProvider(name, description, handler) - Add dynamic provider
  • WithInteractiveFunction(name, handler) - Add interactive function
  • WithCLICommand(name, description, handler) - Add CLI command
  • Build() - Build the plugin

License

MIT License - see LICENSE file for details.

Documentation

Overview

Package sdk provides the MOPS SDK for building plugins

Index

Constants

View Source
const (
	PluginName      = "mops-plugin"
	ProtocolVersion = 1
)

Variables

View Source
var PluginMap = map[string]plugin.Plugin{
	PluginName: &MopsPlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

func Main

func Main(pluginImpl Plugin)

Main is a convenience function to serve a plugin

Types

type ActionExecutor

type ActionExecutor interface {
	GetActionType() string
	Execute(entry MenuEntry, input string) ActionResult
}

ActionExecutor is an interface that executes actions

type ActionExecutorRPC

type ActionExecutorRPC struct {
	ActionType string
}

type ActionExecutorRPCClient

type ActionExecutorRPCClient struct {
	// contains filtered or unexported fields
}

func (*ActionExecutorRPCClient) Execute

func (a *ActionExecutorRPCClient) Execute(entry MenuEntry, input string) ActionResult

func (*ActionExecutorRPCClient) GetActionType

func (a *ActionExecutorRPCClient) GetActionType() string

type ActionResult

type ActionResult struct {
	Success     bool
	Output      string
	Error       error
	ShowOutput  bool
	Title       string
	IsStreaming bool
	RefreshMenu bool // Indicates if the parent menu should refresh its dynamic content
}

ActionResult represents the result of executing an action

type AppState

type AppState int

AppState represents the application state

const (
	MainMenu AppState = iota
	DoneScreen
)

type BuildTarget

type BuildTarget struct {
	OS     string `yaml:"os"`
	Arch   string `yaml:"arch"`
	Output string `yaml:"output"`
}

BuildTarget represents a build target configuration

type CLICommandExecuteArgs

type CLICommandExecuteArgs struct {
	Name string
	Args []string
}

type CLICommandExecuteResponse

type CLICommandExecuteResponse struct {
	Output string
	Error  error
}

type CLICommandHandler

type CLICommandHandler func(args []string) error

CLICommandHandler handles CLI command execution

type CLICommandInfo

type CLICommandInfo struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Usage       string   `json:"usage"`
	Examples    []string `json:"examples"`
}

CLICommandInfo describes a CLI command provided by the plugin

type DynamicProvider

type DynamicProvider interface {
	GetName() string
	GetEntries(param string) ([]MenuEntry, error)
}

DynamicProvider is an interface that provides dynamic menu entries

type DynamicProviderRPC

type DynamicProviderRPC struct {
	Name string
}

RPC argument types

type DynamicProviderRPCClient

type DynamicProviderRPCClient struct {
	// contains filtered or unexported fields
}

RPC client implementations

func (*DynamicProviderRPCClient) GetEntries

func (d *DynamicProviderRPCClient) GetEntries(param string) ([]MenuEntry, error)

func (*DynamicProviderRPCClient) GetName

func (d *DynamicProviderRPCClient) GetName() string

type ExecutorExecuteArgs

type ExecutorExecuteArgs struct {
	ActionType string
	Entry      MenuEntry
	Input      string
}

type InteractiveFunctionCallArgs

type InteractiveFunctionCallArgs struct {
	Name   string
	Params map[string]interface{}
}

type InteractiveFunctionCallResponse

type InteractiveFunctionCallResponse struct {
	Output []string
	Error  error
}

type InteractiveGoFunction

type InteractiveGoFunction func(ctx context.Context, outputChan chan<- string, inputChan <-chan string, params map[string]interface{}) error

InteractiveGoFunction represents a Go function that can be executed with real-time interaction

type Menu struct {
	ID            string          `yaml:"id"`
	Title         string          `yaml:"title"`
	Input         bool            `yaml:"input,omitempty"`
	Entries       []MenuEntry     `yaml:"entries,omitempty"`
	ConfirmAction *MenuAction     `yaml:"confirm_action,omitempty"`
	CancelKey     string          `yaml:"cancel_key,omitempty"`
	CancelNextID  string          `yaml:"cancel_next_id,omitempty"`
	Provider      string          `yaml:"provider,omitempty"`
	ProviderParam string          `yaml:"provider_param,omitempty"`
	Map           map[string]Menu `yaml:"-"`
}

Menu represents a menu definition

type MenuAction struct {
	Action  string                 `yaml:"action"`
	Target  string                 `yaml:"target,omitempty"`
	Command string                 `yaml:"command,omitempty"`
	NextID  string                 `yaml:"next_id,omitempty"`
	Params  map[string]interface{} `yaml:"params,omitempty"`
}

MenuAction represents a menu action

type MenuConfig struct {
	Menus []Menu `yaml:"menus"`
}

MenuConfig represents the menu configuration

type MenuEntry struct {
	Key           string                 `yaml:"key"`
	Label         string                 `yaml:"label"`
	Action        string                 `yaml:"action"`
	Target        string                 `yaml:"target,omitempty"`
	Message       string                 `yaml:"message,omitempty"`
	Command       string                 `yaml:"command,omitempty"`
	NextID        string                 `yaml:"next_id,omitempty"`
	FilePath      string                 `yaml:"file_path,omitempty"`
	Params        map[string]interface{} `yaml:"params,omitempty"`
	IsDynamic     bool                   `yaml:"-"`
	KeyBind       string                 `yaml:"key_bind,omitempty"`
	IsInteractive bool                   `yaml:"is_interactive,omitempty"`
}

MenuEntry represents a menu entry

type MopsPlugin

type MopsPlugin struct {
	// Impl Injection
	Impl Plugin
}

MopsPlugin is the implementation of plugin.Plugin so we can serve/consume this

func (*MopsPlugin) Client

func (p *MopsPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*MopsPlugin) Server

func (p *MopsPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type MopsVersionConstraint

type MopsVersionConstraint struct {
	MinVersion string `yaml:"min_version"`
	MaxVersion string `yaml:"max_version"`
}

MopsVersionConstraint represents MOPS version compatibility

type NavMsg struct {
	Next          AppState
	NextID        string
	Data          any
	IsBack        bool
	Params        map[string]interface{}
	TitleOverride string
}

NavMsg represents navigation messages

type PlatformInfo

type PlatformInfo struct {
	OS   string `json:"os"`
	Arch string `json:"arch"`
}

PlatformInfo represents platform information for plugin distribution

func GetCurrentPlatform

func GetCurrentPlatform() PlatformInfo

GetCurrentPlatform returns the current platform information

type Plugin

type Plugin interface {
	GetInfo() PluginInfo
	Initialize(config map[string]any) error
	RegisterProviders() []DynamicProvider
	RegisterExecutors() []ActionExecutor
	RegisterInteractiveFunctions() map[string]InteractiveGoFunction
	GetCLICommands() (map[string]CLICommandHandler, error)
	GetMenuEntries() (map[string][]MenuEntry, error)
	Cleanup() error
	ValidateConfig(config map[string]any) error
}

Plugin is the interface that all plugins must implement

type PluginBase

type PluginBase struct {
	// contains filtered or unexported fields
}

PluginBase provides a base implementation for mops plugins

func NewPluginBase

func NewPluginBase(info PluginInfo) *PluginBase

NewPluginBase creates a new plugin base

func (*PluginBase) AddCLICommand

func (p *PluginBase) AddCLICommand(name string, handler CLICommandHandler)

AddCLICommand adds a CLI command to the plugin

func (*PluginBase) AddExecutor

func (p *PluginBase) AddExecutor(executor ActionExecutor)

AddExecutor adds an action executor to the plugin

func (*PluginBase) AddInteractiveFunction

func (p *PluginBase) AddInteractiveFunction(name string, fn InteractiveGoFunction)

AddInteractiveFunction adds an interactive function to the plugin

func (*PluginBase) AddMenuEntry

func (p *PluginBase) AddMenuEntry(menuID string, entry MenuEntry)

AddMenuEntry adds a menu entry to a specific menu

func (*PluginBase) AddProvider

func (p *PluginBase) AddProvider(provider DynamicProvider)

AddProvider adds a dynamic provider to the plugin

func (*PluginBase) Cleanup

func (p *PluginBase) Cleanup() error

Cleanup performs cleanup when the plugin is being unloaded

func (*PluginBase) GetCLICommands

func (p *PluginBase) GetCLICommands() (map[string]CLICommandHandler, error)

GetCLICommands returns CLI command handlers

func (*PluginBase) GetInfo

func (p *PluginBase) GetInfo() PluginInfo

GetInfo returns metadata about the plugin

func (*PluginBase) GetMenuEntries

func (p *PluginBase) GetMenuEntries() (map[string][]MenuEntry, error)

GetMenuEntries returns menu entries that should be added to menus

func (*PluginBase) Initialize

func (p *PluginBase) Initialize(config map[string]any) error

Initialize sets up the plugin with the provided config

func (*PluginBase) RegisterExecutors

func (p *PluginBase) RegisterExecutors() []ActionExecutor

RegisterExecutors registers action executors with mops

func (*PluginBase) RegisterInteractiveFunctions

func (p *PluginBase) RegisterInteractiveFunctions() map[string]InteractiveGoFunction

RegisterInteractiveFunctions registers interactive functions with mops

func (*PluginBase) RegisterProviders

func (p *PluginBase) RegisterProviders() []DynamicProvider

RegisterProviders registers dynamic providers with mops

func (*PluginBase) ValidateConfig

func (p *PluginBase) ValidateConfig(config map[string]any) error

ValidateConfig validates the plugin configuration

func (*PluginBase) WithCLICommand

func (p *PluginBase) WithCLICommand(name string, handler CLICommandHandler) *PluginBase

WithCLICommand adds a CLI command to the plugin base

func (*PluginBase) WithInteractiveFunction

func (p *PluginBase) WithInteractiveFunction(name string, fn InteractiveGoFunction) *PluginBase

WithInteractiveFunction adds an interactive function to the plugin base

func (*PluginBase) WithMenuEntry

func (p *PluginBase) WithMenuEntry(menuID string, entry MenuEntry) *PluginBase

WithMenuEntry adds a menu entry to the plugin base

func (*PluginBase) WithSimpleExecutor

func (p *PluginBase) WithSimpleExecutor(actionType string, fn func(entry MenuEntry, input string) ActionResult) *PluginBase

WithSimpleExecutor adds a simple executor to the plugin base

func (*PluginBase) WithSimpleProvider

func (p *PluginBase) WithSimpleProvider(name string, fn func(param string) ([]MenuEntry, error)) *PluginBase

WithSimpleProvider adds a simple provider to the plugin base

type PluginBuilder

type PluginBuilder struct {
	// contains filtered or unexported fields
}

PluginBuilder provides a fluent interface for creating plugins

func NewPluginBuilder

func NewPluginBuilder(name, version, description string) *PluginBuilder

NewPluginBuilder creates a new plugin builder

func (*PluginBuilder) AddDependency

func (b *PluginBuilder) AddDependency(dependency string) *PluginBuilder

AddDependency adds a dependency to the plugin

func (*PluginBuilder) AddTag

func (b *PluginBuilder) AddTag(tag string) *PluginBuilder

AddTag adds a tag to the plugin

func (*PluginBuilder) Build

func (b *PluginBuilder) Build() Plugin

Build creates the plugin

func (*PluginBuilder) SetAuthor

func (b *PluginBuilder) SetAuthor(author string) *PluginBuilder

SetAuthor sets the plugin author

func (*PluginBuilder) SetDefaultConfig

func (b *PluginBuilder) SetDefaultConfig(config map[string]any) *PluginBuilder

SetDefaultConfig sets the default configuration

func (*PluginBuilder) SetHomepage

func (b *PluginBuilder) SetHomepage(homepage string) *PluginBuilder

SetHomepage sets the plugin homepage

func (*PluginBuilder) SetLicense

func (b *PluginBuilder) SetLicense(license string) *PluginBuilder

SetLicense sets the plugin license

func (*PluginBuilder) SetMopsVersions

func (b *PluginBuilder) SetMopsVersions(minVersion, maxVersion string) *PluginBuilder

SetMopsVersions sets the MOPS version constraints

func (*PluginBuilder) WithCLICommand

func (b *PluginBuilder) WithCLICommand(name, description string, handler CLICommandHandler) *PluginBuilder

WithCLICommand adds a CLI command

func (*PluginBuilder) WithInteractiveFunction

func (b *PluginBuilder) WithInteractiveFunction(name string, fn InteractiveGoFunction) *PluginBuilder

WithInteractiveFunction adds an interactive function

func (*PluginBuilder) WithMenuEntry

func (b *PluginBuilder) WithMenuEntry(menuID string, entry MenuEntry) *PluginBuilder

WithMenuEntry adds a menu entry

func (*PluginBuilder) WithSimpleExecutor

func (b *PluginBuilder) WithSimpleExecutor(actionType string, fn func(entry MenuEntry, input string) ActionResult) *PluginBuilder

WithSimpleExecutor adds a simple executor

func (*PluginBuilder) WithSimpleProvider

func (b *PluginBuilder) WithSimpleProvider(name, description string, fn func(param string) ([]MenuEntry, error)) *PluginBuilder

WithSimpleProvider adds a simple provider

type PluginInfo

type PluginInfo struct {
	Name               string           `json:"name"`
	Version            string           `json:"version"`
	Description        string           `json:"description"`
	Author             string           `json:"author"`
	License            string           `json:"license"`
	Homepage           string           `json:"homepage"`
	MopsMinVersion     string           `json:"mops_min_version"`
	MopsMaxVersion     string           `json:"mops_max_version"`
	Dependencies       []string         `json:"dependencies"`
	Tags               []string         `json:"tags"`
	CLICommands        []CLICommandInfo `json:"cli_commands"`
	DefaultConfig      map[string]any   `json:"default_config"`
	Platform           PlatformInfo     `json:"platform"`
	SupportedPlatforms []PlatformInfo   `json:"supported_platforms"`
}

PluginInfo contains metadata about a plugin

type PluginInfoRPC

type PluginInfoRPC struct {
	Name               string           `json:"name"`
	Version            string           `json:"version"`
	Description        string           `json:"description"`
	Author             string           `json:"author"`
	License            string           `json:"license"`
	Homepage           string           `json:"homepage"`
	MopsMinVersion     string           `json:"mops_min_version"`
	MopsMaxVersion     string           `json:"mops_max_version"`
	Dependencies       []string         `json:"dependencies"`
	Tags               []string         `json:"tags"`
	CLICommands        []CLICommandInfo `json:"cli_commands"`
	DefaultConfigJSON  string           `json:"default_config_json"` // JSON-encoded config to avoid GOB issues
	Platform           PlatformInfo     `json:"platform"`
	SupportedPlatforms []PlatformInfo   `json:"supported_platforms"`
}

PluginInfoRPC is a GOB-safe version of PluginInfo for RPC transport

func NewPluginInfoRPC

func NewPluginInfoRPC(info PluginInfo) (PluginInfoRPC, error)

NewPluginInfoRPC converts PluginInfo to PluginInfoRPC

func (*PluginInfoRPC) ToPluginInfo

func (rpc *PluginInfoRPC) ToPluginInfo() (PluginInfo, error)

ToPluginInfo converts PluginInfoRPC to PluginInfo

type PluginMetadata

type PluginMetadata struct {
	Name          string                `yaml:"name"`
	Version       string                `yaml:"version"`
	Description   string                `yaml:"description"`
	Author        string                `yaml:"author"`
	License       string                `yaml:"license"`
	Homepage      string                `yaml:"homepage"`
	Repository    string                `yaml:"repository"`
	Tags          []string              `yaml:"tags"`
	MopsVersion   MopsVersionConstraint `yaml:"mops_version"`
	BuildTargets  []BuildTarget         `yaml:"build_targets"`
	DefaultConfig map[string]any        `yaml:"default_config"`
	CLICommands   []CLICommandInfo      `yaml:"cli_commands"`
}

PluginMetadata represents the plugin.yaml file structure

type PluginRPCClient

type PluginRPCClient struct {
	// contains filtered or unexported fields
}

PluginRPCClient is an implementation of Plugin that talks over RPC.

func (*PluginRPCClient) Cleanup

func (g *PluginRPCClient) Cleanup() error

func (*PluginRPCClient) GetCLICommands

func (g *PluginRPCClient) GetCLICommands() (map[string]CLICommandHandler, error)

func (*PluginRPCClient) GetInfo

func (g *PluginRPCClient) GetInfo() PluginInfo

func (*PluginRPCClient) GetMenuEntries

func (g *PluginRPCClient) GetMenuEntries() (map[string][]MenuEntry, error)

func (*PluginRPCClient) Initialize

func (g *PluginRPCClient) Initialize(config map[string]any) error

func (*PluginRPCClient) RegisterExecutors

func (g *PluginRPCClient) RegisterExecutors() []ActionExecutor

func (*PluginRPCClient) RegisterInteractiveFunctions

func (g *PluginRPCClient) RegisterInteractiveFunctions() map[string]InteractiveGoFunction

func (*PluginRPCClient) RegisterProviders

func (g *PluginRPCClient) RegisterProviders() []DynamicProvider

func (*PluginRPCClient) ValidateConfig

func (g *PluginRPCClient) ValidateConfig(config map[string]any) error

type PluginRPCServer

type PluginRPCServer struct {
	Impl Plugin
}

PluginRPCServer is the RPC server that PluginRPCClient talks to

func (*PluginRPCServer) CallInteractiveFunction

func (s *PluginRPCServer) CallInteractiveFunction(args *InteractiveFunctionCallArgs, resp *InteractiveFunctionCallResponse) error

func (*PluginRPCServer) Cleanup

func (s *PluginRPCServer) Cleanup(args interface{}, resp *error) error

func (*PluginRPCServer) ExecuteAction

func (s *PluginRPCServer) ExecuteAction(args *ExecutorExecuteArgs, resp *ActionResult) error

func (*PluginRPCServer) ExecuteCLICommand

func (s *PluginRPCServer) ExecuteCLICommand(args *CLICommandExecuteArgs, resp *CLICommandExecuteResponse) error

func (*PluginRPCServer) GenerateProviderEntries

func (s *PluginRPCServer) GenerateProviderEntries(args *ProviderGenerateEntriesArgs, resp *[]MenuEntry) error

func (*PluginRPCServer) GetCLICommands

func (s *PluginRPCServer) GetCLICommands(args interface{}, resp *map[string]CLICommandInfo) error

func (*PluginRPCServer) GetInfo

func (s *PluginRPCServer) GetInfo(args interface{}, resp *PluginInfoRPC) error

func (*PluginRPCServer) GetMenuEntries

func (s *PluginRPCServer) GetMenuEntries(args interface{}, resp *map[string][]MenuEntry) error

func (*PluginRPCServer) Initialize

func (s *PluginRPCServer) Initialize(configJSON string, resp *error) error

func (*PluginRPCServer) RegisterExecutors

func (s *PluginRPCServer) RegisterExecutors(args interface{}, resp *[]ActionExecutorRPC) error

func (*PluginRPCServer) RegisterInteractiveFunctions

func (s *PluginRPCServer) RegisterInteractiveFunctions(args interface{}, resp *map[string]string) error

func (*PluginRPCServer) RegisterProviders

func (s *PluginRPCServer) RegisterProviders(args interface{}, resp *[]DynamicProviderRPC) error

func (*PluginRPCServer) ValidateConfig

func (s *PluginRPCServer) ValidateConfig(args map[string]any, resp *error) error

type ProviderGenerateEntriesArgs

type ProviderGenerateEntriesArgs struct {
	Name  string
	Param string
}

type Registry

type Registry interface {
	RegisterProvider(provider DynamicProvider)
	RegisterExecutor(executor ActionExecutor)
	GetProvider(name string) (DynamicProvider, bool)
	GetExecutor(actionType string) (ActionExecutor, bool)
	ListProviders() []string
	ListExecutors() []string
}

Registry interface for managing providers and executors

type RepositoryPlugin

type RepositoryPlugin struct {
	Name        string                           `json:"name"`
	Version     string                           `json:"version"`
	Description string                           `json:"description"`
	Author      string                           `json:"author"`
	License     string                           `json:"license"`
	Homepage    string                           `json:"homepage"`
	Repository  string                           `json:"repository"`
	Tags        []string                         `json:"tags"`
	MopsVersion MopsVersionConstraint            `json:"mops_version"`
	Platforms   map[string]RepositoryPluginAsset `json:"platforms"`
	Checksums   map[string]string                `json:"checksums"`
	LastUpdated time.Time                        `json:"last_updated"`
}

RepositoryPlugin represents a plugin entry in a repository registry

type RepositoryPluginAsset

type RepositoryPluginAsset struct {
	Platform    PlatformInfo `json:"platform"`
	DownloadURL string       `json:"download_url"`
	Size        int64        `json:"size"`
	Checksum    string       `json:"checksum"`
	Filename    string       `json:"filename"`
}

RepositoryPluginAsset represents a platform-specific plugin asset

type RepositoryRegistry

type RepositoryRegistry struct {
	Repository struct {
		Name        string    `json:"name"`
		Description string    `json:"description"`
		URL         string    `json:"url"`
		LastUpdated time.Time `json:"last_updated"`
		Version     string    `json:"version"`
	} `json:"repository"`
	Plugins map[string]RepositoryPlugin `json:"plugins"`
}

RepositoryRegistry represents a registry of all plugins in a repository

type SimpleExecutor

type SimpleExecutor struct {
	// contains filtered or unexported fields
}

SimpleExecutor provides a convenient way to create basic executors

func NewSimpleExecutor

func NewSimpleExecutor(actionType string, fn func(entry MenuEntry, input string) ActionResult) *SimpleExecutor

NewSimpleExecutor creates a new simple executor

func (*SimpleExecutor) Execute

func (e *SimpleExecutor) Execute(entry MenuEntry, input string) ActionResult

Execute executes the action

func (*SimpleExecutor) GetActionType

func (e *SimpleExecutor) GetActionType() string

GetActionType returns the action type

type SimpleProvider

type SimpleProvider struct {
	// contains filtered or unexported fields
}

SimpleProvider provides a convenient way to create basic providers

func NewSimpleProvider

func NewSimpleProvider(name string, fn func(param string) ([]MenuEntry, error)) *SimpleProvider

NewSimpleProvider creates a new simple provider

func (*SimpleProvider) GetEntries

func (p *SimpleProvider) GetEntries(param string) ([]MenuEntry, error)

GetEntries returns the menu entries

func (*SimpleProvider) GetName

func (p *SimpleProvider) GetName() string

GetName returns the provider name

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL