dialog

package
v11.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 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 (
	// 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
	// ResponseUndo stands for the user choosing to undo the unfinished run state.
	ResponseUndo = Response{"undo"} //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.

func SwitchBranch added in v11.1.0

func SwitchBranch(roots domain.LocalBranchNames, selected domain.LocalBranchName, lineage config.Lineage) (selection domain.LocalBranchName, validSelection bool, err error)

queryBranch lets the user select a new branch via a visual dialog. Indicates via `validSelection` whether the user made a valid selection.

Types

type Builder added in v11.1.0

type Builder struct {
	Entries ModalSelectEntries
	Lineage config.Lineage
}

Builder builds up the switch-branch dialog entries.

func NewBuilder added in v11.1.0

func NewBuilder(lineage config.Lineage) Builder

func (*Builder) AddEntryAndChildren added in v11.1.0

func (self *Builder) AddEntryAndChildren(branch domain.LocalBranchName, indent int) error

AddEntryAndChildren adds the given branch and all its child branches to the given entries collection.

func (*Builder) CreateEntries added in v11.1.0

func (self *Builder) CreateEntries(roots domain.LocalBranchNames, selected domain.LocalBranchName) error

createEntries provides all the entries for the branch dialog.

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