menu

package
v0.0.0-...-4332b5b Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Teonet CLI application menu.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

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

Batch is data and methods to Save and Execute saved Teonet Menu commands.

func NewBatch

func NewBatch(menu *Menu) *Batch

NewBatch creates new Batch object

func (*Batch) Run

func (b *Batch) Run(appShort, name string) (err error)

Run executes commands from batch config file

func (Batch) Save

func (b Batch) Save(appShort, name string, prefix string, batch []string) (err error)

Save batch to config file

type CmdHelp

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

CmdHelp help command

func (CmdHelp) Compliter

func (c CmdHelp) Compliter() (cmpl []Compliter)

func (CmdHelp) Exec

func (c CmdHelp) Exec(line string) (err error)

func (CmdHelp) Help

func (c CmdHelp) Help() string

func (CmdHelp) Name

func (c CmdHelp) Name() string

type Compliter

type Compliter readline.PrefixCompleterInterface // Readline compliter type

type Item

type Item interface {
	Name() string           // Get command name
	Help() string           // Get command quick help string
	Exec(line string) error // Execute command
	Compliter() []Compliter // Command compliter
}
type Menu struct {
	// contains filtered or unexported fields
}

Menu is Teonet CLI application menu

func New

func New(appShort string) (cmd *Menu, err error)

New creates new Teonet CLI application menu

func (m *Menu) Add(items ...Item)

Add command (menu item)

func (m Menu) ExecuteCommand(line string) (err error)

ExecuteCommand executes command using input command line

func (m Menu) MakeCommand(command string, help string,
	exec func(line string) error, comp ...func() []Compliter) Item

MakeCommand create command object for Add command. The first argument 'command' may by static string or dynamic function which return Items name

func (m *Menu) MakeCompliterFromString(strings []string) (cmpl []Compliter)

MakeCompliterFromString returns compliter created from input string slice

func (m *Menu) Run() (err error)

Run menu

func (m Menu) Split(line, delimiter string) (res []string)

Split line by delemiter helper function

func (m Menu) SplitComma(line string) (res []string)

SplitComma split line by comma helper function

func (m Menu) SplitSpace(line string) (res []string)

SplitSpace split line by space helper function

Jump to

Keyboard shortcuts

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