main 5041353

update.go RawHistoryFolder

1package styles
2
3import (
4	"fmt"
5
6	"github.com/charmbracelet/lipgloss"
7)
8
9// UpdateRenderer renders update status messages with styled output.
10type UpdateRenderer struct {
11	theme *Theme
12}
13
14// NewUpdateRenderer creates a new update renderer with the given theme.
15func NewUpdateRenderer(theme *Theme) *UpdateRenderer {
16	return &UpdateRenderer{theme: theme}
17}
18
19// RenderChecking renders the "checking for updates" message.
20func (*UpdateRenderer) RenderChecking(spinner string) string {
21	return fmt.Sprintf("\n  %s Checking for updates...\n", spinner)
22}
23
24// RenderUpToDate renders the "already up to date" message.
25func (r *UpdateRenderer) RenderUpToDate(version string) string {
26	iconStyle := lipgloss.NewStyle().Foreground(r.theme.Success)
27	versionStyle := r.theme.Highlight
28
29	return fmt.Sprintf(
30		"\n  %s Already up to date (%s)\n",
31		iconStyle.Render(IconCheck),
32		versionStyle.Render(version),
33	)
34}
35
36// RenderAvailable renders the "update available" message.
37func (r *UpdateRenderer) RenderAvailable(current, latest, releaseURL string) string {
38	iconStyle := lipgloss.NewStyle().Foreground(r.theme.Accent)
39	versionStyle := r.theme.Highlight
40	urlStyle := r.theme.Subtle
41
42	return fmt.Sprintf(
43		"\n  %s Update available: %s %s %s\n     %s\n",
44		iconStyle.Render(IconRocket),
45		versionStyle.Render(current),
46		iconStyle.Render(IconArrow),
47		versionStyle.Render(latest),
48		urlStyle.Render(releaseURL),
49	)
50}
51
52// RenderDownloading renders the "downloading" message with spinner.
53func (r *UpdateRenderer) RenderDownloading(spinner, version string) string {
54	versionStyle := r.theme.Highlight
55
56	return fmt.Sprintf(
57		"\n  %s Downloading %s...\n",
58		spinner,
59		versionStyle.Render(version),
60	)
61}
62
63// RenderStaged renders the "update staged" success message.
64func (r *UpdateRenderer) RenderStaged(version string) string {
65	iconStyle := lipgloss.NewStyle().Foreground(r.theme.Success)
66	versionStyle := r.theme.Highlight
67
68	return fmt.Sprintf(
69		"\n  %s Update %s downloaded and staged\n  %s Will be applied when this command exits\n",
70		iconStyle.Render(IconCheck),
71		versionStyle.Render(version),
72		iconStyle.Render(IconCheck),
73	)
74}
75
76// RenderError renders an error message.
77func (r *UpdateRenderer) RenderError(err error) string {
78	iconStyle := lipgloss.NewStyle().Foreground(r.theme.Error)
79
80	return fmt.Sprintf(
81		"\n  %s Update failed: %v\n",
82		iconStyle.Render(IconX),
83		err,
84	)
85}
86
87// RenderCannotAutoUpdate renders the "cannot auto-update" message.
88func (r *UpdateRenderer) RenderCannotAutoUpdate(current, latest, releaseURL string) string {
89	iconStyle := lipgloss.NewStyle().Foreground(r.theme.Warning)
90	versionStyle := r.theme.Highlight
91	urlStyle := r.theme.Subtle
92
93	return fmt.Sprintf(
94		"\n  %s Update available: %s %s %s\n"+
95			"  %s Cannot auto-update: binary is not writable\n"+
96			"     Download manually: %s\n",
97		iconStyle.Render(IconRocket),
98		versionStyle.Render(current),
99		iconStyle.Render(IconArrow),
100		versionStyle.Render(latest),
101		iconStyle.Render(IconWarning),
102		urlStyle.Render(releaseURL),
103	)
104}
105
106// RenderDevBuild renders the "dev build" skip message.
107func (r *UpdateRenderer) RenderDevBuild() string {
108	iconStyle := lipgloss.NewStyle().Foreground(r.theme.Warning)
109	return fmt.Sprintf(
110		"\n  %s Development build - update check skipped\n",
111		iconStyle.Render(IconInfo),
112	)
113}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close