app

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	Extensions       map[string]Extension
	ExtensionRoot    string
	ExtensionConfigs map[string]ExtensionConfig
	ConfigRoot       string
}
var Sunbeam Api

func (Api) AddExtension

func (api Api) AddExtension(name string, config ExtensionConfig) error

func (Api) RemoveExtension

func (api Api) RemoveExtension(configName string) error

type Detail

type Detail struct {
	Actions []ScriptAction `json:"actions"`
	DetailData
}

type DetailData

type DetailData struct {
	Preview    string           `json:"preview"`
	PreviewCmd string           `json:"previewCmd"`
	Metadatas  []ScriptMetadata `json:"metadatas"`
}

type Extension

type Extension struct {
	Title       string        `json:"title" yaml:"title"`
	Description string        `json:"description" yaml:"description"`
	Name        string        `json:"name" yaml:"name"`
	PostInstall string        `json:"postInstall" yaml:"postInstall"`
	Preferences []ScriptParam `json:"preferences" yaml:"preferences"`

	Requirements []ExtensionRequirement `json:"requirements" yaml:"requirements"`
	RootItems    []RootItem             `json:"rootItems" yaml:"rootItems"`
	Scripts      map[string]Script      `json:"scripts" yaml:"scripts"`

	Url url.URL
}

func ParseManifest

func ParseManifest(bytes []byte) (extension Extension, err error)

func (Extension) Dir

func (m Extension) Dir() string

type ExtensionConfig

type ExtensionConfig struct {
	Root   string `json:"root"`
	Remote string `json:"remote,omitempty"`
}

type ExtensionManifest

type ExtensionManifest []ExtensionConfig

type ExtensionRequirement

type ExtensionRequirement struct {
	Which    string `json:"which" yaml:"which"`
	HomePage string `json:"homePage" yaml:"homePage"`
}

func (ExtensionRequirement) Check

func (r ExtensionRequirement) Check() bool

type FormInput

type FormInput struct {
	Type        string `json:"type"`
	Required    bool   `json:"required"`
	Title       string `json:"title"`
	Placeholder string `json:"placeholder"`
	Default     any    `json:"default"`

	TrueSubstitution  string `json:"trueSubstitution"`
	FalseSubstitution string `json:"falseSubstitution"`

	Data []struct {
		Title string `json:"title,omitempty"`
		Value string `json:"value,omitempty"`
	} `json:"data,omitempty"`
	Label string `json:"label"`
}

type RootItem

type RootItem struct {
	Extension string
	Script    string
	Title     string
	Subtitle  string
	With      map[string]any
}

type Script

type Script struct {
	Name        string
	Command     string        `json:"command" yaml:"command"`
	Description string        `json:"description" yaml:"description"`
	Preferences []ScriptParam `json:"preferences" yaml:"preferences"`
	Mode        string        `json:"mode" yaml:"mode"`
	Cwd         string        `json:"cwd" yaml:"cwd"`
	Params      []ScriptParam `json:"params" yaml:"params"`
	ShowPreview bool          `json:"showPreview" yaml:"showPreview"`
}

func (Script) Cmd

func (s Script) Cmd(with map[string]string) (string, error)

func (Script) IsPage

func (s Script) IsPage() bool

type ScriptAction

type ScriptAction struct {
	Title    string `json:"title" yaml:"title"`
	Type     string `json:"type" yaml:"type"`
	Shortcut string `json:"shortcut,omitempty" yaml:"shortcut"`

	Text string `json:"text,omitempty" yaml:"textfield"`

	Url  string `json:"url,omitempty" yaml:"url"`
	Path string `json:"path,omitempty" yaml:"path"`

	Extension string `json:"extension,omitempty" yaml:"extension"`
	Script    string `json:"script,omitempty" yaml:"script"`
	Command   string `json:"command,omitempty" yaml:"command"`
	Dir       string

	OnSuccess string                 `json:"onSuccess,omitempty" yaml:"onSuccess"`
	With      map[string]ScriptInput `json:"with,omitempty" yaml:"with"`
}

type ScriptInput

type ScriptInput struct {
	Value any
	FormInput
}

func (ScriptInput) GetValue

func (si ScriptInput) GetValue() (string, error)

func (*ScriptInput) UnmarshalJSON

func (si *ScriptInput) UnmarshalJSON(bytes []byte) (err error)

func (*ScriptInput) UnmarshalYAML

func (si *ScriptInput) UnmarshalYAML(value *yaml.Node) (err error)

type ScriptItem

type ScriptItem struct {
	Id       string `json:"id"`
	Title    string `json:"title"`
	Subtitle string `json:"subtitle"`
	DetailData
	Accessories []string       `json:"accessories"`
	Actions     []ScriptAction `json:"actions"`
}

func ParseListItems

func ParseListItems(output string) (items []ScriptItem, err error)

func (ScriptItem) PreviewCommand

func (li ScriptItem) PreviewCommand() *exec.Cmd

type ScriptMetadata

type ScriptMetadata struct {
	Title string `json:"title"`
	Value string `json:"value"`
}

type ScriptParam

type ScriptParam struct {
	Name  string
	Input FormInput `json:"input"`
}

Jump to

Keyboard shortcuts

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