menu

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package menu displays a Terminal UI based text menu to choose boot options from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry interface {
	// Label is the string displayed to the user in the menu.
	Label() string

	// Load is called when the entry is chosen, but does not transfer
	// execution to another process or kernel.
	Load() error

	// Exec transfers execution to another process or kernel.
	//
	// Exec either returns an error or does not return at all.
	Exec() error

	// IsDefault indicates that this action should be run by default if the
	// user didn't make an entry choice.
	IsDefault() bool
}

Entry is a menu entry.

func Choose

func Choose(input *os.File, entries ...Entry) Entry

Choose presents the user a menu on input to choose an entry from and returns that entry.

func OSImages

func OSImages(verbose bool, imgs ...boot.OSImage) []Entry

OSImages returns menu entries for the given OSImages.

func ShowMenuAndLoad

func ShowMenuAndLoad(input *os.File, entries ...Entry) Entry

ShowMenuAndLoad lets the user choose one of entries and loads it. If no entry is chosen by the user, an entry whose IsDefault() is true will be returned.

The user is left to call Entry.Exec when this function returns.

type OSImageAction

type OSImageAction struct {
	boot.OSImage
	Verbose bool
}

OSImageAction is a menu.Entry that boots an OSImage.

func (OSImageAction) Exec

func (oia OSImageAction) Exec() error

Exec executes the loaded image.

func (OSImageAction) IsDefault

func (OSImageAction) IsDefault() bool

IsDefault returns true -- this action should be performed in order by default if the user did not choose a boot entry.

func (OSImageAction) Load

func (oia OSImageAction) Load() error

Load implements Entry.Load by loading the OS image into memory.

type Reboot

type Reboot struct{}

Reboot is a menu.Entry that reboots the machine.

func (Reboot) Exec

func (Reboot) Exec() error

Exec reboots the machine using sys_reboot.

func (Reboot) IsDefault

func (Reboot) IsDefault() bool

IsDefault indicates that this should not be run as a default action.

func (Reboot) Label

func (Reboot) Label() string

Label is the label to show to the user.

func (Reboot) Load

func (Reboot) Load() error

Load does nothing.

type StartShell

type StartShell struct{}

StartShell is a menu.Entry that starts a LinuxBoot shell.

func (StartShell) Exec

func (StartShell) Exec() error

Exec implements Entry.Exec by running /bin/defaultsh.

func (StartShell) IsDefault

func (StartShell) IsDefault() bool

IsDefault indicates that this should not be run as a default action.

func (StartShell) Label

func (StartShell) Label() string

Label is the label to show to the user.

func (StartShell) Load

func (StartShell) Load() error

Load does nothing.

Jump to

Keyboard shortcuts

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