Documentation
¶
Overview ¶
Package tui is the human review interface: a full-screen Bubble Tea program.
Index ¶
- func Confirm(in io.Reader, out io.Writer, getenv func(string) string, title ConfirmHeading, ...) func(publish.Preview) (publish.Confirmation, error)
- type Config
- type ConfirmHeading
- type ConfirmModel
- type GlyphSet
- type Model
- func (m *Model) Decide(findingID string, fn func(*draft.Draft) error) (bool, error)
- func (m *Model) Err() error
- func (m *Model) Init() tea.Cmd
- func (m *Model) PublishedURL() string
- func (m *Model) Returned() (Returned, bool)
- func (m *Model) StopWatching()
- func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m *Model) View() tea.View
- func (m *Model) WaitForSend()
- type Returned
- type Screen
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
func Confirm(in io.Reader, out io.Writer, getenv func(string) string, title ConfirmHeading, screen *Screen) func(publish.Preview) (publish.Confirmation, error)
Confirm runs the confirmation view full screen for loupe publish. title is what the header names, which loupe publish builds from the run and the flags it was given. screen is nil except in a test, as Config.Screen is.
Types ¶
type Config ¶
type Config struct {
Dir string
Getenv func(string) string
Now func() time.Time
// Output is where the program draws; it decides which colors the terminal supports.
Output io.Writer
// GitHub is called when the human publishes and, with WatchPR, for each check of the live pull request. A failed
// check only tags the header, so reviewing never needs credentials.
GitHub func() (github.Client, error)
// WatchPR re-reads the pull request while review is open (specs/050-pr-state-awareness). Only loupe review sets
// it; the standalone confirmation and tests that publish do not.
WatchPR bool
// OpenURL opens the published review in a browser; nil offers no o on the published screen.
OpenURL func(string) error
// UpdateNotice, when set, shows when review opens.
UpdateNotice string
// Screen is set only by a test, to stand in for a terminal.
Screen *Screen
}
type ConfirmHeading ¶
type ConfirmHeading struct {
// contains filtered or unexported fields
}
ConfirmHeading is what the confirmation header names: the two things a wrong keypress could change, and where they go.
func ConfirmTitle ¶
func ConfirmTitle(ref, action, inline string, comments int) ConfirmHeading
type ConfirmModel ¶
type ConfirmModel struct {
// contains filtered or unexported fields
}
ConfirmModel is the confirmation view as a program of its own, for loupe publish.
func NewConfirmModel ¶
func NewConfirmModel(preview publish.Preview, getenv func(string) string, output io.Writer, title ConfirmHeading) *ConfirmModel
func (*ConfirmModel) Confirmed ¶
func (c *ConfirmModel) Confirmed() bool
Confirmed is true only when the program ended on y or p.
func (*ConfirmModel) Init ¶
func (c *ConfirmModel) Init() tea.Cmd
func (*ConfirmModel) Message ¶
func (c *ConfirmModel) Message() string
Message is the opening prose the human typed, empty when they typed none.
func (*ConfirmModel) View ¶
func (c *ConfirmModel) View() tea.View
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the review program. It holds no lock: every decision goes through draft.Mutate at the displayed version.
func (*Model) Decide ¶
Decide applies fn to the finding as displayed and reports whether it was recorded. A refusal reloads the draft and becomes the notice, so the human sees the finding as it now is. Other findings the draft brings with it are named in m.elsewhere for the caller's notice.
func (*Model) Err ¶
Err is the failure that ended the program, if any; refusals during review are notices, not errors.
func (*Model) PublishedURL ¶
PublishedURL is the review this program sent, empty when it sent none.
func (*Model) StopWatching ¶
func (m *Model) StopWatching()
StopWatching cancels a check in flight. The program calls nothing after it quits, so reviewSession calls this once the program has ended.
func (*Model) WaitForSend ¶
func (m *Model) WaitForSend()
WaitForSend blocks until a review the human confirmed has its outcome recorded, for when the program ended before that, as on a signal.
type Returned ¶
Returned is what a return in this program handed the applier, for the line review leaves in the terminal.
type Screen ¶
type Screen struct{ Width, Height int }
Screen is a test's stand-in for a terminal, which bubbletea cannot ask for a size. The program starts at its size and drops no keys as it opens or moves to the next finding: those pauses guard a human's typeahead, and a test types only once the screen shows what it waits for.