menu

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Home

func Home() string

Home retrieves path of kwt home e.g. /home/james/.kwt

func Ingest

func Ingest(source string) error

Ingest a file into system store

func List

func List() []string

List generates list of menu names, home first, pwd after

func Map added in v0.6.0

func Map() map[string]Menu

Map loads all available menus

func MapRepo added in v0.6.0

func MapRepo(repo string) map[string]Menu

MapRepo loads available menus from repo

func Pwd added in v0.6.0

func Pwd() string

Pwd path used to find menus i.e. .kwt

func Render

func Render(action Action) (string, error)

Render an action into a command

Types

type Action

type Action struct {
	Name     string   `json:"name" binding:"required"`
	Aliases  []string `json:"aliases"`
	Help     string   `json:"help"`
	Template string   `json:"template" binding:"required"`
	Params   []Param  `json:"params"`
}

Action struct: a thing a user can do

type Menu struct {
	Name    string   `json:"name" binding:"required"`
	Aliases []string `json:"aliases"`
	Version string   `json:"version"`
	Help    string   `json:"help"`
	Actions []Action `json:"actions" binding:"required"`
	Hash    string   `json:"hash"`
	Path    string   `json:"path"`
}

Menu struct: a list of actions

func Load

func Load(name string) (Menu, error)

Load loads the menu identified by name

func Parse

func Parse(data []byte) (Menu, error)

Parse a menu given a blob

type Param

type Param struct {
	Name    string   `json:"name" binding:"required"`
	Aliases []string `json:"aliases"`
	Help    string   `json:"help"`
	Value   string   `json:"value"`
}

Param struct: a parameter for a action

Jump to

Keyboard shortcuts

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