v2.31.0-dev17 bd898f0

presentation.go RawHistoryFolder

1package cli
2
3import (
4	"fmt"
5	"io"
6
7	"github.com/bnema/zerowrap"
8
9	"github.com/bnema/gordon/internal/adapters/in/cli/ui/styles"
10)
11
12var cliWriteLine = func(w io.Writer, msg string) error {
13	_, err := fmt.Fprintln(w, msg)
14	return err
15}
16
17var cliWritef = func(w io.Writer, format string, args ...any) error {
18	_, err := fmt.Fprintf(w, format, args...)
19	return err
20}
21
22// cliLogConfig is the shared logger configuration for CLI commands that run
23// outside the server lifecycle. Level "warn" keeps normal output clean while
24// still surfacing actionable warnings from adapters.
25var cliLogConfig = zerowrap.Config{
26	Level:  "warn",
27	Format: "console",
28}
29
30func cliLogger() zerowrap.Logger {
31	return zerowrap.New(cliLogConfig)
32}
33
34func cliRenderTitle(msg string) string {
35	return styles.Theme.Title.Render(msg)
36}
37
38func cliRenderMuted(msg string) string {
39	return styles.Theme.Muted.Render(msg)
40}
41
42func cliRenderEmptyState(msg string) string {
43	return cliRenderMuted(msg)
44}
45
46func cliRenderListItem(msg string) string {
47	const selected = false // CLI list items are never in a selected/highlighted state
48	return styles.RenderListItem(msg, selected)
49}
50
51func cliRenderMeta(label, value string) string {
52	return styles.Theme.Bold.Render(label) + " " + styles.Theme.Muted.Render(value)
53}
54
55func cliRenderSuccess(msg string) string {
56	return styles.RenderSuccess(msg)
57}
58
59func cliRenderWarning(msg string) string {
60	return styles.RenderWarning(msg)
61}
62
63func cliRenderInfo(msg string) string {
64	return styles.RenderInfo(msg)
65}
66
67func shortContainerID(id string) string {
68	if len(id) > 12 {
69		return id[:12]
70	}
71
72	return id
73}

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 7

Tags 106

↑↓ moveenter openesc close