dialog

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 5 Imported by: 0

README

dialog Build Status Go Report Card License

Simple wrapper for the dialog executable.

Online documentation

Screenshots

screenshot 1 screenshot 2

Features and limitations

Supports only these types:

  • Message box
  • Yes/No box
  • Menu box

Example use

package main

import (
	"fmt"
	"github.com/xyproto/dialog"
)

func main() {
	d := dialog.New(80, 24)
	answeredYes, err := d.YesNo("Do you want cake?")
	if err != nil {
		panic(err)
	}
	if answeredYes {
		fmt.Println("You answered: yes")
		fmt.Println("The cake is a lie. Haha!")
	} else {
		fmt.Println("You answered: no")
		fmt.Println("Fine.")
	}
}

Requirements

  • Go >= 1.3

General info

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialog

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

Dialog represents a message box, menu or similar text widget. Also contains the path to the dialog executable.

func New

func New(width, height int) *Dialog

New will create a new Dialog struct

func (*Dialog) Menu

func (d *Dialog) Menu(text string, menuheight int, menuItemPairs map[string]string) (string, error)

Menu can present a menu for the user Takes: * A message for the user * The desired height (counted in lines) * A map of menu itmes (item label -> item value) Returns the chosen item value.

func (*Dialog) MsgBox

func (d *Dialog) MsgBox(text string) error

MsgBox can display a message box with the given text to the user

func (*Dialog) SetPath

func (d *Dialog) SetPath(path string)

SetPath will set the full path to the dialog utility (eg. "/usr/bin/dialog")

func (*Dialog) YesNo

func (d *Dialog) YesNo(text string) (bool, error)

YesNo presents a yes/no choice to the user. Returns true if "yes".

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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