dialog

package
v10.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package dialog allows the user to enter configuration data via CLI dialogs and prompts.

Index

Constants

View Source
const (
	PerennialBranchOption = "<none> (perennial branch)"
)

Variables

View Source
var (
	// ResponseAbort stands for the user choosing to abort the unfinished run state.
	ResponseAbort = Response{"abort"} //nolint:gochecknoglobals
	// ResponseContinue stands for the user choosing to continue the unfinished run state.
	ResponseContinue = Response{"continue"} //nolint:gochecknoglobals
	// ResponseDiscard stands for the user choosing to discard the unfinished run state.
	ResponseDiscard = Response{"discard"} //nolint:gochecknoglobals
	// ResponseQuit stands for the user choosing to quit the program.
	ResponseQuit = Response{"quit"} //nolint:gochecknoglobals
	// ResponseSkip stands for the user choosing to continue the unfinished run state by skipping the current branch.
	ResponseSkip = Response{"skip"} //nolint:gochecknoglobals
)

Functions

func EnterMainBranch

func EnterMainBranch(localBranches domain.LocalBranchNames, oldMainBranch domain.LocalBranchName, backend *git.BackendCommands) (domain.LocalBranchName, error)

EnterMainBranch lets the user select a new main branch for this repo. This includes asking the user and updating the respective setting.

func EnterParent

func EnterParent(branch, defaultParent domain.LocalBranchName, lineage config.Lineage, branches domain.BranchInfos) (domain.LocalBranchName, error)

EnterParent lets the user select a new parent for the given branch.

func EnterPerennialBranches

func EnterPerennialBranches(backend *git.BackendCommands, branches domain.Branches) (domain.BranchTypes, error)

EnterPerennialBranches lets the user update the perennial branches. This includes asking the user and updating the respective settings based on the user selection.

func Initialize

func Initialize()

Initialize configures the prompts to work on Windows.

func ModalSelect

func ModalSelect(entries ModalSelectEntries, initialValue string) (*string, error)

ModalSelect allows the user to select a value from the given entries. Entries can be arbitrarily formatted. The given initial value is preselected.

func MultiSelect

func MultiSelect(args MultiSelectArgs) ([]string, error)

MultiSelect displays a visual dialog that allows the user to select multiple entries amongst the given options.

func Select

func Select(opts SelectArgs) (string, error)

Select displays a visual dialog that allows the user to select one of the given options.

func SelectAuthor

func SelectAuthor(branch string, authors []string) (string, error)

SelectAuthor allows the user to select an author amongst a given list of authors.

func SelectSquashCommitAuthor

func SelectSquashCommitAuthor(branch domain.LocalBranchName, authors []string) (string, error)

SelectSquashCommitAuthor allows the user to select an author amongst a given list of authors.

Types

type ModalSelectEntries

type ModalSelectEntries []ModalSelectEntry

ModalSelectEntries is a collection of ModalEntry.

func (ModalSelectEntries) IndexOfValue

func (self ModalSelectEntries) IndexOfValue(value string) *int

IndexOfValue provides the index of the entry with the given value, or nil if the given value is not in the list.

func (ModalSelectEntries) Strings

func (self ModalSelectEntries) Strings() []string

type ModalSelectEntry

type ModalSelectEntry struct {
	Text  string // the text to display
	Value string // the return value
}

ModalSelectEntry contains one of the many entries that the user can choose from.

type MultiSelectArgs

type MultiSelectArgs struct {
	Options  []string
	Defaults []string
	Message  string
}

type Response

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

func AskHowToHandleUnfinishedRunState

func AskHowToHandleUnfinishedRunState(command string, endBranch domain.LocalBranchName, endTime time.Time, canSkip bool) (Response, error)

AskHowToHandleUnfinishedRunState prompts the user for how to handle the unfinished run state.

func (Response) String

func (self Response) String() string

type SelectArgs

type SelectArgs struct {
	Options []string
	Default string
	Message string
}

Jump to

Keyboard shortcuts

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