dialog

package
v14.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package dialog provides high-level screens through which the user can enter data into Git Town.

Index

Constants

View Source
const (
	PushNewBranchesEntryYes pushNewBranchesEntry = "yes, push new branches to origin"
	PushNewBranchesEntryNo  pushNewBranchesEntry = "no, new branches remain local until synced"
)
View Source
const (
	ShipDeleteTrackingBranchEntryYes shipDeleteTrackingBranchEntry = `yes, "git ship" should delete tracking branches`
	ShipDeleteTrackingBranchEntryNo  shipDeleteTrackingBranchEntry = `no, my code hosting platform deletes tracking branches`
)
View Source
const (
	SyncBeforeShipEntryYes syncBeforeShipEntry = `yes, "git ship" should also sync the branch`
	SyncBeforeShipEntryNo  syncBeforeShipEntry = `no, "git ship" should not sync the branch`
)
View Source
const (
	SyncPerennialStrategyEntryMerge  syncPerennialStrategyEntry = `merge updates from the tracking branch into perennial branches`
	SyncPerennialStrategyEntryRebase syncPerennialStrategyEntry = `rebase perennial branches against their tracking branch`
)
View Source
const (
	SyncUpstreamEntryYes syncUpstreamEntry = `yes, receive updates from the upstream repo`
	SyncUpstreamEntryNo  syncUpstreamEntry = `no, don't receive updates from upstream`
)
View Source
const (
	ResponseContinue = Response("continue") // continue the unfinished run state
	ResponseDiscard  = Response("discard")  // discard the unfinished run state
	ResponseQuit     = Response("quit")     // quit the program
	ResponseSkip     = Response("skip")     // continue the unfinished run state by skipping the current branch
	ResponseUndo     = Response("undo")     // undo the unfinished run state
)
View Source
const (
	HostingPlatformHelp = `` /* 225-byte string literal not displayed */

)
View Source
const (
	MainBranchHelp = `` /* 198-byte string literal not displayed */

)
View Source
const (
	OriginHostnameHelp = `` /* 143-byte string literal not displayed */

)
View Source
const (
	PerennialBranchesHelp = `` /* 230-byte string literal not displayed */

)
View Source
const (
	PerennialRegexHelp = `` /* 137-byte string literal not displayed */

)
View Source
const (
	PushHookHelp = `` /* 340-byte string literal not displayed */

)
View Source
const (
	PushNewBranchesHelp = `` /* 380-byte string literal not displayed */

)
View Source
const (
	ShipDeleteTrackingBranchHelp = `` /* 190-byte string literal not displayed */

)
View Source
const (
	SyncBeforeShipHelp = `` /* 501-byte string literal not displayed */

)
View Source
const (
	SyncFeatureStrategyHelp = `` /* 230-byte string literal not displayed */

)
View Source
const (
	SyncPerennialStrategyHelp = `` /* 195-byte string literal not displayed */

)
View Source
const (
	SyncUpstreamHelp = `` /* 358-byte string literal not displayed */

)

Variables

View Source
var PerennialBranchOption = gitdomain.LocalBranchName("<none> (perennial branch)") //nolint:gochecknoglobals

Functions

func Aliases

func Aliases(allAliasableCommands configdomain.AliasableCommands, existingAliases configdomain.Aliases, inputs components.TestInput) (configdomain.Aliases, bool, error)

Aliases lets the user select which Git Town commands should have shorter aliases. This includes asking the user and updating the respective settings based on the user selection.

func DetermineAliasResult

func DetermineAliasResult(selections []AliasSelection, allAliasableCommands configdomain.AliasableCommands, existingAliases configdomain.Aliases) configdomain.Aliases

func DetermineAliasSelectionText

func DetermineAliasSelectionText(selectedCommands configdomain.AliasableCommands) string

func GitHubToken

GitHubToken lets the user enter the GitHub API token.

func GitLabToken

GitLabToken lets the user enter the GitHub API token.

func GiteaToken

GiteaToken lets the user enter the Gitea API token.

func MainBranch

func MainBranch(localBranches gitdomain.LocalBranchNames, defaultEntry gitdomain.LocalBranchName, inputs components.TestInput) (gitdomain.LocalBranchName, bool, error)

MainBranch lets the user select a new main branch for this repo.

func OriginHostname

GitHubToken lets the user enter the GitHub API token.

func ParentCandidateNames added in v14.1.0

func ParentCandidateNames(args ParentArgs) gitdomain.LocalBranchNames

func PerennialBranches

func PerennialBranches(localBranches gitdomain.LocalBranchNames, oldPerennialBranches gitdomain.LocalBranchNames, mainBranch gitdomain.LocalBranchName, inputs components.TestInput) (gitdomain.LocalBranchNames, bool, error)

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

func PerennialRegex

PerennialRegex lets the user enter the GitHub API token.

func PushHook

func SelectSquashCommitAuthor

func SelectSquashCommitAuthor(branch gitdomain.LocalBranchName, authors []gitdomain.Author, dialogTestInputs components.TestInput) (gitdomain.Author, bool, error)

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

func SwitchBranch

func SwitchBranch(localBranches gitdomain.LocalBranchNames, initialBranch gitdomain.LocalBranchName, lineage configdomain.Lineage, allBranches gitdomain.BranchInfos, uncommittedChanges bool, inputs components.TestInput) (gitdomain.LocalBranchName, bool, error)

func SwitchBranchCursorPos

func SwitchBranchCursorPos(entries []SwitchBranchEntry, initialBranch gitdomain.LocalBranchName) int

SwitchBranchCursorPos provides the initial cursor position for the "switch branch" components.

func Welcome

func Welcome(inputs components.TestInput) (bool, error)

MainBranch lets the user select a new main branch for this repo.

Types

type AliasSelection

type AliasSelection int

AliasSelection encodes the status of a checkbox in the alias components.

const (
	AliasSelectionNone  AliasSelection = iota // the user chose to not set this alias
	AliasSelectionGT                          // the user chose to set this alias to the corresponding Git Town command
	AliasSelectionOther                       // the user chose to keep the alias calling an external command
)

func NewAliasSelections

func NewAliasSelections(aliasableCommands configdomain.AliasableCommands, existingAliases configdomain.Aliases) []AliasSelection

type AliasesModel

type AliasesModel struct {
	list.List[configdomain.AliasableCommand]
	AllAliasableCommands configdomain.AliasableCommands // all Git Town commands that can be aliased
	CurrentSelections    []AliasSelection               // the status of the list entries
	OriginalAliases      configdomain.Aliases           // the Git Town aliases as they currently exist on disk
	// contains filtered or unexported fields
}

func (AliasesModel) Checked

func (AliasesModel) Init

func (self AliasesModel) Init() tea.Cmd

func (*AliasesModel) RotateCurrentEntry

func (self *AliasesModel) RotateCurrentEntry()

RotateCurrentEntry switches the status of the currently selected list entry to the next status.

func (*AliasesModel) SelectAll

func (self *AliasesModel) SelectAll()

SelectAll checks all entries in the list.

func (*AliasesModel) SelectNone

func (self *AliasesModel) SelectNone()

SelectNone unchecks all entries in the list.

func (AliasesModel) Update

func (self AliasesModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (AliasesModel) View

func (self AliasesModel) View() string

type ConfigStorageOption

type ConfigStorageOption string
const (
	ConfigStorageOptionFile ConfigStorageOption = `configuration file`
	ConfigStorageOptionGit  ConfigStorageOption = `Git metadata`
)

func ConfigStorage

func ConfigStorage(hasConfigFile bool, inputs components.TestInput) (ConfigStorageOption, bool, error)

func (ConfigStorageOption) Short

func (self ConfigStorageOption) Short() string

func (ConfigStorageOption) String

func (self ConfigStorageOption) String() string

type ParentArgs

type ParentArgs struct {
	Branch          gitdomain.LocalBranchName
	DefaultChoice   gitdomain.LocalBranchName
	DialogTestInput components.TestInput
	Lineage         configdomain.Lineage
	LocalBranches   gitdomain.LocalBranchNames
	MainBranch      gitdomain.LocalBranchName
}

type ParentOutcome added in v14.2.0

type ParentOutcome int

ParentOutcome describes the selection that the user made in the `Parent` dialog.

const (
	ParentOutcomeAborted         ParentOutcome = iota // the user aborted the dialog
	ParentOutcomePerennialBranch                      // the user chose the "perennial branch" option
	ParentOutcomeSelectedParent                       // the user selected one of the branches
)

func Parent

Parent lets the user select the parent branch for the given branch.

type PerennialBranchesModel

type PerennialBranchesModel struct {
	list.List[gitdomain.LocalBranchName]
	Selections []int
	// contains filtered or unexported fields
}

func (*PerennialBranchesModel) CheckedEntries

func (self *PerennialBranchesModel) CheckedEntries() gitdomain.LocalBranchNames

checkedEntries provides all checked list entries.

func (*PerennialBranchesModel) DisableCurrentEntry

func (self *PerennialBranchesModel) DisableCurrentEntry()

disableCurrentEntry unchecks the currently selected list entry.

func (*PerennialBranchesModel) EnableCurrentEntry

func (self *PerennialBranchesModel) EnableCurrentEntry()

enableCurrentEntry checks the currently selected list entry.

func (PerennialBranchesModel) Init

func (self PerennialBranchesModel) Init() tea.Cmd

func (*PerennialBranchesModel) IsRowChecked

func (self *PerennialBranchesModel) IsRowChecked(row int) bool

isRowChecked indicates whether the row with the given number is checked or not.

func (*PerennialBranchesModel) IsSelectedRowChecked

func (self *PerennialBranchesModel) IsSelectedRowChecked() bool

isSelectedRowChecked indicates whether the currently selected list entry is checked or not.

func (*PerennialBranchesModel) ToggleCurrentEntry

func (self *PerennialBranchesModel) ToggleCurrentEntry()

toggleCurrentEntry unchecks the currently selected list entry if it is checked, and checks it if it is unchecked.

func (PerennialBranchesModel) Update

func (self PerennialBranchesModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (PerennialBranchesModel) View

func (self PerennialBranchesModel) View() string

type Response

type Response string

func AskHowToHandleUnfinishedRunState

func AskHowToHandleUnfinishedRunState(command string, endBranch gitdomain.LocalBranchName, endTime time.Time, canSkip bool, dialogTestInput components.TestInput) (Response, bool, error)

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

func (Response) String

func (self Response) String() string

type SwitchBranchEntry

type SwitchBranchEntry struct {
	Branch        gitdomain.LocalBranchName
	Indentation   string
	OtherWorktree bool
}

func SwitchBranchEntries

func SwitchBranchEntries(localBranches gitdomain.LocalBranchNames, lineage configdomain.Lineage, allBranches gitdomain.BranchInfos) []SwitchBranchEntry

SwitchBranchEntries provides the entries for the "switch branch" components.

func (SwitchBranchEntry) String

func (sbe SwitchBranchEntry) String() string

type SwitchModel

type SwitchModel struct {
	list.List[SwitchBranchEntry]
	InitialBranchPos   int  // position of the currently checked out branch in the list
	UncommittedChanges bool // whether the workspace has uncommitted changes
}

func (SwitchModel) Init

func (self SwitchModel) Init() tea.Cmd

func (SwitchModel) Update

func (self SwitchModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (SwitchModel) View

func (self SwitchModel) View() string

Directories

Path Synopsis
Package dialog contains shared components to build full dialog screens out of.
Package dialog contains shared components to build full dialog screens out of.
list
Package list provides a generic list implementation to be used inside BubbleTea-based dialog components.
Package list provides a generic list implementation to be used inside BubbleTea-based dialog components.

Jump to

Keyboard shortcuts

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