types

package
v1.0.0-rc.23 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CopyAction   = "copy"
	OpenAction   = "open"
	PushAction   = "push"
	ExecAction   = "exec"
	PasteAction  = "paste"
	ReloadAction = "reload"
	FetchAction  = "fetch"
	EvalAction   = "eval"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Title  string     `json:"title,omitempty"`
	Type   ActionType `json:"type"`
	Key    string     `json:"key,omitempty"`
	Inputs []Input    `json:"inputs,omitempty"`

	// copy
	Text string `json:"text,omitempty"`

	// open
	Target string `json:"target,omitempty"`

	// push
	Page string `json:"page,omitempty"`

	// fetch
	Request *Request `json:"request,omitempty"`

	// eval
	Code *Expression `json:"expression,omitempty"`

	// run
	Command *Command `json:"command,omitempty"`

	OnSuccess OnSuccessType `json:"onSuccess,omitempty"`

	Exit bool `json:"-"`
}

func (Action) Output

func (a Action) Output(ctx context.Context) ([]byte, error)

type ActionType

type ActionType string

type Body

type Body []byte

func (*Body) UnmarshalJSON

func (b *Body) UnmarshalJSON(data []byte) error

type Command added in v0.9.0

type Command struct {
	Name  string   `json:"name"`
	Args  []string `json:"args,omitempty"`
	Input string   `json:"input,omitempty"`
	Dir   string   `json:"dir,omitempty"`
}

func (Command) Cmd added in v0.9.0

func (c Command) Cmd(ctx context.Context) *exec.Cmd

func (Command) Output added in v0.9.0

func (c Command) Output(ctx context.Context) ([]byte, error)

func (Command) Run added in v0.9.0

func (c Command) Run(ctx context.Context) error

func (*Command) UnmarshalJSON added in v0.9.0

func (c *Command) UnmarshalJSON(data []byte) error
type DropDownItem struct {
	Title string `json:"title"`
	Value string `json:"value"`
}

type EmptyView added in v0.9.23

type EmptyView struct {
	Text    string   `json:"text,omitempty"`
	Actions []Action `json:"actions,omitempty"`
}

type Expression

type Expression struct {
	Code string `json:"code"`
	Args []any  `json:"args,omitempty"`
}

func (Expression) Request

func (e Expression) Request() *Request

func (*Expression) UnmarshalJSON

func (e *Expression) UnmarshalJSON(data []byte) error

type FormInputType

type FormInputType string
const (
	TextFieldInput FormInputType = "textfield"
	TextAreaInput  FormInputType = "textarea"
	DropDownInput  FormInputType = "dropdown"
	CheckboxInput  FormInputType = "checkbox"
)

type Input added in v0.7.0

type Input struct {
	Name        string        `json:"name"`
	Type        FormInputType `json:"type"`
	Title       string        `json:"title"`
	Placeholder string        `json:"placeholder,omitempty"`
	Default     any           `json:"default,omitempty"`
	Optional    bool          `json:"optional,omitempty"`

	// Only for dropdown
	Items []DropDownItem `json:"items,omitempty"`

	// Only for checkbox
	Label             string `json:"label,omitempty"`
	TrueSubstitution  string `json:"trueSubstitution,omitempty"`
	FalseSubstitution string `json:"falseSubstitution,omitempty"`
}

func NewCheckbox added in v0.9.23

func NewCheckbox(name string, title string, label string) Input

func NewDropDown added in v0.9.23

func NewDropDown(name string, title string, items ...DropDownItem) Input

func NewTextAreaInput added in v0.9.23

func NewTextAreaInput(name string, title string, placeholder string) Input

func NewTextInput added in v0.9.23

func NewTextInput(name string, title string, placeholder string) Input

type ListItem

type ListItem struct {
	Id          string        `json:"id,omitempty"`
	Title       string        `json:"title"`
	Subtitle    string        `json:"subtitle,omitempty"`
	Detail      *TextProvider `json:"detail,omitempty"`
	Accessories []string      `json:"accessories,omitempty"`
	Actions     []Action      `json:"actions,omitempty"`
}

type OnSuccessType

type OnSuccessType string
const (
	CopyOnSuccess   OnSuccessType = "copy"
	PasteOnSuccess  OnSuccessType = "paste"
	OpenOnSuccess   OnSuccessType = "open"
	ReloadOnSuccess OnSuccessType = "reload"
)

type Page

type Page struct {
	Type    PageType `json:"type"`
	Title   string   `json:"title,omitempty"`
	Actions []Action `json:"actions,omitempty"`

	// form
	SubmitAction *Action `json:"submitAction,omitempty"`

	// Detail page
	Text       string      `json:"text,omitempty"`
	Command    *Command    `json:"command,omitempty"`
	Request    *Request    `json:"request,omitempty"`
	Expression *Expression `json:"expression,omitempty"`

	// List page
	ShowDetail    bool          `json:"showDetail,omitempty"`
	OnQueryChange *TextProvider `json:"onQueryChange,omitempty"`
	EmptyView     *EmptyView    `json:"emptyView,omitempty"`
	Items         []ListItem    `json:"items,omitempty"`
}

type PageType

type PageType string
const (
	DetailPage PageType = "detail"
	ListPage   PageType = "list"
	FormPage   PageType = "form"
)

type Request

type Request struct {
	Url     string            `json:"url"`
	Method  string            `json:"method,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Body    Body              `json:"body,omitempty"`
}

func (Request) Do

func (r Request) Do(ctx context.Context) ([]byte, error)

type TextProvider

type TextProvider struct {
	Text       string      `json:"text,omitempty"`
	Command    *Command    `json:"command,omitempty"`
	Request    *Request    `json:"request,omitempty"`
	Expression *Expression `json:"expression,omitempty"`
}

func (TextProvider) Output

func (pp TextProvider) Output(ctx context.Context) ([]byte, error)

Jump to

Keyboard shortcuts

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