v0.13.0 976176a

runner.go RawHistoryFolder

1package cli
2
3import (
4	"fmt"
5	"os"
6
7	"github.com/bnema/dumber/internal/cli"
8	"github.com/bnema/dumber/internal/config"
9	"github.com/bnema/dumber/internal/logging"
10)
11
12// Execute runs the CLI functionality using the existing CLI package
13func Execute(version, commit, buildDate string) {
14	// Initialize configuration system
15	if err := config.Init(); err != nil {
16		fmt.Fprintf(os.Stderr, "Error initializing configuration: %v\n", err)
17		os.Exit(1)
18	}
19
20	// Initialize logging system for CLI mode (file logging only, no output capture)
21	cfg := config.Get()
22	if err := logging.Init(
23		cfg.Logging.LogDir,
24		cfg.Logging.Level,
25		cfg.Logging.Format,
26		cfg.Logging.EnableFileLog,
27		cfg.Logging.MaxSize,
28		cfg.Logging.MaxBackups,
29		cfg.Logging.MaxAge,
30		cfg.Logging.Compress,
31	); err != nil {
32		fmt.Fprintf(os.Stderr, "Warning: failed to initialize logging: %v\n", err)
33	}
34
35	// Start configuration watching for live reload
36	if err := config.Watch(); err != nil {
37		// Don't exit on watch error, just warn
38		fmt.Fprintf(os.Stderr, "Warning: failed to start config watching: %v\n", err)
39	}
40
41	rootCmd := cli.NewRootCmd(version, commit, buildDate)
42
43	// Handle dmenu flag at the root level for direct integration
44	if len(os.Args) > 1 && os.Args[1] == "--dmenu" {
45		handleDmenuMode()
46		return
47	}
48
49	// Execute the root command
50	if err := rootCmd.Execute(); err != nil {
51		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
52		os.Exit(1)
53	}
54}
55
56// handleDmenuMode processes dmenu-specific functionality
57func handleDmenuMode() {
58	// Create a temporary CLI instance to handle dmenu mode
59	cliInstance, err := cli.NewCLI()
60	if err != nil {
61		fmt.Fprintf(os.Stderr, "Error initializing CLI: %v\n", err)
62		os.Exit(1)
63	}
64	defer func() {
65		if closeErr := cliInstance.Close(); closeErr != nil {
66			fmt.Fprintf(os.Stderr, "Warning: failed to close database: %v\n", closeErr)
67		}
68	}()
69
70	// Generate dmenu options
71	dmenuCmd := cli.NewDmenuCmd()
72	if err := dmenuCmd.RunE(dmenuCmd, []string{}); err != nil {
73		fmt.Fprintf(os.Stderr, "Error in dmenu mode: %v\n", err)
74		if closeErr := cliInstance.Close(); closeErr != nil {
75			fmt.Fprintf(os.Stderr, "Warning: failed to close database: %v\n", closeErr)
76		}
77		os.Exit(1)
78	}
79}

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