plugins

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name        string
	Description string
	Usage       string
	Handler     func(args []string) error
}

Command represents a plugin command

type Event

type Event struct {
	Type EventType
	Data interface{}
}

Event represents various events in the application

type EventType

type EventType int

EventType represents the type of event

const (
	EventViewChanged EventType = iota
	EventJobSubmitted
	EventJobCompleted
	EventNodeStateChanged
	EventClusterHealthChanged
)

type KeyBinding

type KeyBinding struct {
	Key         rune
	Modifiers   tcell.ModMask
	Description string
	Handler     func() error
}

KeyBinding represents a custom key binding

type Manager

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

Manager implements the PluginManager interface

func NewManager

func NewManager(ctx context.Context, client dao.SlurmClient) *Manager

NewManager creates a new plugin manager

func (*Manager) GetAllPlugins

func (m *Manager) GetAllPlugins() []Plugin

GetAllPlugins returns all loaded plugins

func (*Manager) GetCommands

func (m *Manager) GetCommands() []Command

GetCommands returns all commands from all plugins

func (*Manager) GetKeyBindings

func (m *Manager) GetKeyBindings() []KeyBinding

GetKeyBindings returns all key bindings from all plugins

func (*Manager) GetPlugin

func (m *Manager) GetPlugin(name string) Plugin

GetPlugin returns a plugin by name

func (*Manager) GetViews

func (m *Manager) GetViews() []View

GetViews returns all views from all plugins

func (*Manager) LoadPlugin

func (m *Manager) LoadPlugin(path string) error

LoadPlugin loads a plugin from the given path

func (*Manager) LoadPluginsFromDirectory

func (m *Manager) LoadPluginsFromDirectory(dir string) error

LoadPluginsFromDirectory loads all plugins from a directory

func (*Manager) SendEvent

func (m *Manager) SendEvent(event Event) error

SendEvent sends an event to all plugins

func (*Manager) UnloadAllPlugins

func (m *Manager) UnloadAllPlugins() error

UnloadAllPlugins unloads all plugins

func (*Manager) UnloadPlugin

func (m *Manager) UnloadPlugin(name string) error

UnloadPlugin unloads a plugin

type Plugin

type Plugin interface {
	// GetInfo returns basic plugin information
	GetInfo() PluginInfo

	// Initialize initializes the plugin with the given context and client
	Initialize(ctx context.Context, client dao.SlurmClient) error

	// GetCommands returns the commands this plugin provides
	GetCommands() []Command

	// GetViews returns the views this plugin provides
	GetViews() []View

	// GetKeyBindings returns custom key bindings this plugin provides
	GetKeyBindings() []KeyBinding

	// OnEvent is called when various events occur in the application
	OnEvent(event Event) error

	// Cleanup is called when the plugin is being unloaded
	Cleanup() error
}

Plugin represents a s9s plugin

type PluginInfo

type PluginInfo struct {
	Name        string
	Version     string
	Description string
	Author      string
	Website     string
}

PluginInfo contains basic information about a plugin

type PluginManager

type PluginManager interface {
	// LoadPlugin loads a plugin from the given path
	LoadPlugin(path string) error

	// LoadPluginsFromDirectory loads all plugins from a directory
	LoadPluginsFromDirectory(dir string) error

	// GetPlugin returns a plugin by name
	GetPlugin(name string) Plugin

	// GetAllPlugins returns all loaded plugins
	GetAllPlugins() []Plugin

	// GetCommands returns all commands from all plugins
	GetCommands() []Command

	// GetViews returns all views from all plugins
	GetViews() []View

	// GetKeyBindings returns all key bindings from all plugins
	GetKeyBindings() []KeyBinding

	// SendEvent sends an event to all plugins
	SendEvent(event Event) error

	// UnloadPlugin unloads a plugin
	UnloadPlugin(name string) error

	// UnloadAllPlugins unloads all plugins
	UnloadAllPlugins() error
}

PluginManager manages all loaded plugins

type View

type View interface {
	// GetName returns the view name
	GetName() string

	// GetTitle returns the view title
	GetTitle() string

	// Render returns the tview primitive for this view
	Render() tview.Primitive

	// OnKey handles key events
	OnKey(event *tcell.EventKey) *tcell.EventKey

	// Refresh updates the view data
	Refresh() error

	// Init initializes the view
	Init(ctx context.Context) error
}

View represents a plugin-provided view

Jump to

Keyboard shortcuts

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