Documentation
¶
Overview ¶
Package ui implements gu on top of the ninebox shell. It depends only on internal/forge: no view may import a provider package.
The shell owns the frame stack, the list, the sidebar, the banner, the prompt bar, the help and the refresh timer. gu owns what a row means: merge requests, issues, pipelines, stacks, and the screens that read them.
Index ¶
- func New(f forge.Forge, profile, host string, readOnly bool, start StartAt, ...) *ninebox.Model
- type Context
- type Model
- func (m *Model) Attach(nb *ninebox.Model)
- func (m *Model) Categories() []ninebox.Category
- func (m *Model) Command(line string) (tea.Cmd, bool)
- func (m *Model) Commands() []ninebox.Command
- func (m *Model) Describe(payload any, raw bool) (string, bool)
- func (m *Model) Facts() []ninebox.Fact
- func (m *Model) Help() []ninebox.HelpSection
- func (m *Model) Init() tea.Cmd
- func (m *Model) Key(key string) (tea.Cmd, bool)
- func (m *Model) ListActions() []ninebox.Action
- func (m *Model) Message(msg tea.Msg) (tea.Cmd, bool)
- func (m *Model) Start() *frame
- func (m *Model) WebURL(payload any) string
- type Option
- type StartAt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
Name string
// Provider is what the profile is configured for: "gitlab", "github", or
// both. It comes from the config file, so listing costs nothing.
Provider string
// Detail is the config directory backing the profile, which is what
// actually distinguishes two accounts on the same host.
Detail string
Open func(ctx context.Context) (forge.Forge, string, error)
}
Context is one account gu can operate as: a profile, what it is configured with, and how to connect to it.
Open is deferred, and reports the host it ended up on, because resolving that means asking the CLI — a subprocess and often a round-trip per account. Only the context you actually switch to pays for it, so startup stays the cost of one account rather than all of them.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is gu: the application the shell runs. It is a ninebox.App, and holds a pointer back to the shell so its screens can push, prompt and report.
func (*Model) Categories ¶
Categories hands the shell gu's menu. Project-scoped entries are listed even with no project in context — they lead to a picker rather than being silently unavailable, which left the sidebar looking broken from the account view.
func (*Model) Command ¶
Command answers the `:` lines that take an argument, which a name on its own cannot express: `:ctx work` switches account outright, where bare `:ctx` opens the picker above.
func (*Model) Commands ¶
Commands are the words `:` accepts from any screen: gu's navigation vocabulary. The shell tries the open screen's own commands first, so `:merge` on a merge request merges it rather than landing here.
func (*Model) Describe ¶
Describe renders a row for the `d` key, and its untouched provider payload for `y`. Reporting false is what makes `d` on a menu entry do nothing rather than open an empty pane.
func (*Model) Facts ¶
Facts is the banner's left-hand block: the handful of things that decide what an action would do.
Where you are comes first and alone: it is the fact that changes as you move around, and the one worth finding without reading the other three.
func (*Model) Help ¶
func (m *Model) Help() []ninebox.HelpSection
Help is what the shell's own key reference does not cover: the resources gu knows about, and the keys that change them.
func (*Model) Init ¶
Init dials the account when gu was launched without one, and otherwise asks who we are, which the banner needs and no frame provides.
func (*Model) Key ¶
Key answers the list keys the shell does not claim for itself. Moving, filtering, describing, opening in a browser and reloading are the shell's; what is left is what gu can do to a merge request or an issue.
func (*Model) ListActions ¶
ListActions is what gu adds to the list's legend and help. Actions that change something are offered only when they would work.
func (*Model) Message ¶
Message answers gu's own asynchronous results. Anything it does not claim falls through to the shell, which knows about rows, writes and toasts.
type Option ¶
type Option func(*Model)
Option customises gu at construction.
func WithAutoRefresh ¶
WithAutoRefresh re-fetches the open screen every d. Zero switches it off, which is what a disabled setting and a nonsensical interval both resolve to.
func WithCache ¶
WithCache gives gu the caching transport, so a screen can draw itself from disk before it fetches anything and a write can drop what it invalidated. A nil transport switches both off.
func WithConnect ¶
WithConnect hands gu the account to dial, instead of one already dialled. The caller has applied read-only wrapping inside connect, exactly as WithContexts requires of its openers.
This is what keeps authentication off the startup path: New returns immediately, the program runs, and the frame that is already on screen is replaced when the account answers.
func WithContexts ¶
WithContexts supplies the accounts `:ctx` can switch between. The caller has already applied read-only wrapping inside each Open.
It takes a function rather than a list because finding the accounts means scanning the disk for CLI configuration directories, which costs about half a second. Nothing pays for it until `:ctx` is actually used.
func WithIcons ¶
WithIcons selects the glyph set by name: "nerd" (the default), "geometric" for terminals without a patched font, or "ascii" for fonts that manage neither.
func WithStackDir ¶
WithStackDir points the stack views at a directory of stack YAML files.
Source Files
¶
- actions.go
- activity.go
- avatar.go
- blocks.go
- board.go
- boardscreen.go
- ci.go
- commands.go
- comments.go
- contexts.go
- describe.go
- diffkeys.go
- diffload.go
- files.go
- frame.go
- frames.go
- icons.go
- issuepage.go
- keys.go
- messages.go
- model.go
- mrpage.go
- ninebox.go
- page.go
- pipelinegraph.go
- pipelines.go
- review.go
- screenkeys.go
- screens.go
- seed.go
- sidebar.go
- stackpage.go
- stacks.go
- stacks_merge.go
- stacks_new.go
- suggest.go
- view.go
- view_activity.go
- view_diff.go
- view_list.go
- view_page.go
- view_stack.go