cliui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Select

func Select(title string, options []string) (int, string, error)

Select displays an interactive command-line menu with a given title and a list of options, allowing the user to choose one of them.

Parameters:

  • title: A string that will be displayed as the heading for the menu.
  • options: A slice of strings representing the selectable options in the menu.

Returns:

  • int: The zero-based index of the option selected by the user in the `options` slice.
  • string: The actual string value of the option selected by the user.
  • error: An error if the selection process fails or is canceled by the user.

Example usage:

options := []string{"etcd-vm1", "etcd-vm2", "etcd-vm3"}
idx, choice, err := cliui.Select("Please choose one VM:", options)
if err != nil {
    fmt.Println("Selection canceled or failed:", err)
    return
}
fmt.Printf("You selected option %d: %s\n", idx, choice)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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