cmd

package
v1.0.0-exp1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Date    = "unknown"
)

Functions

func Execute

func Execute() error

func NewCmdRun

func NewCmdRun() *cobra.Command

func NewCmdServe

func NewCmdServe(extensionMap ExtensionMap) *cobra.Command

func NewCustomCmd

func NewCustomCmd(name string, extension Extension) (*cobra.Command, error)

func NewExtensionAddCmd

func NewExtensionAddCmd(extensionMap ExtensionMap) *cobra.Command

func NewExtensionCmd added in v0.6.1

func NewExtensionCmd(extensionMap ExtensionMap) *cobra.Command

func NewExtensionCmdRemove

func NewExtensionCmdRemove(extensions ExtensionMap) *cobra.Command

func NewExtensionRenameCmd added in v0.7.0

func NewExtensionRenameCmd(extensions ExtensionMap) *cobra.Command

func NewExtensionUpdateCmd

func NewExtensionUpdateCmd(extensions ExtensionMap) *cobra.Command

func NewValidateCmd added in v0.4.1

func NewValidateCmd() *cobra.Command

func NewValidateManifestCmd

func NewValidateManifestCmd() *cobra.Command

func NewValidatePageCmd

func NewValidatePageCmd() *cobra.Command

Types

type Command

type Command struct {
	Name        string          `json:"name"`
	Title       string          `json:"title"`
	Mode        CommandMode     `json:"mode"`
	Hidden      bool            `json:"hidden,omitempty"`
	Description string          `json:"description,omitempty"`
	Params      []CommandParams `json:"params,omitempty"`
}

type CommandInput

type CommandInput struct {
	Command string         `json:"command"`
	Query   string         `json:"query"`
	Params  map[string]any `json:"params"`
}

type CommandMode

type CommandMode string
const (
	CommandModeList      CommandMode = "filter"
	CommandModeGenerator CommandMode = "generator"
	CommandModeDetail    CommandMode = "detail"
	CommandModeText      CommandMode = "text"
	CommandModeSilent    CommandMode = "silent"
)

type CommandParams

type CommandParams struct {
	Name        string    `json:"name"`
	Type        ParamType `json:"type"`
	Default     any       `json:"default,omitempty"`
	Optional    bool      `json:"optional,omitempty"`
	Description string    `json:"description,omitempty"`
}

type Entrypoint

type Entrypoint []string

func (*Entrypoint) UnmarshalJSON

func (e *Entrypoint) UnmarshalJSON(b []byte) error

type Extension

type Extension struct {
	Origin   string            `json:"origin"`
	Manifest ExtensionManifest `json:"manifest"`
}

func (Extension) Run

func (ext Extension) Run(input CommandInput) ([]byte, error)

type ExtensionManifest added in v0.9.0

type ExtensionManifest struct {
	Title       string     `json:"title"`
	Description string     `json:"description,omitempty"`
	Origin      string     `json:"origin,omitempty"`
	Entrypoint  Entrypoint `json:"entrypoint,omitempty"`
	Commands    []Command  `json:"commands"`
}

func LoadManifest

func LoadManifest(origin *url.URL) (ExtensionManifest, error)

type ExtensionMap

type ExtensionMap map[string]Extension

func LoadExtensions

func LoadExtensions() (ExtensionMap, error)

func (ExtensionMap) Save

func (e ExtensionMap) Save() error

type ParamType

type ParamType string
const (
	ParamTypeString  ParamType = "string"
	ParamTypeBoolean ParamType = "boolean"
)

Jump to

Keyboard shortcuts

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