v0.26.0 ae3a77a

root.go RawHistoryFolder

1// Package cmd provides Cobra CLI commands for dumber.
2package cmd
3
4import (
5	"fmt"
6	"os"
7
8	"github.com/spf13/cobra"
9
10	"github.com/bnema/dumber/internal/cli"
11	"github.com/bnema/dumber/internal/domain/build"
12)
13
14var (
15	app       *cli.App
16	buildInfo build.Info
17	rootCmd   = &cobra.Command{
18		Use:   "dumber",
19		Short: "A fully unfeatured unbloated browser for tiling WMs",
20		Long: `Dumber - a dumb browser that works like your favorite terminal multiplexer.
21
22A fully unfeatured unbloated browser for tiling WMs, built with GTK4 and WebKitGTK.
23
24Features:
25  - Wayland native (Sway, Hyprland, River, Niri, etc.)
26  - Tabs and workspaces with split or stacked panes
27  - Keyboard-driven workflow inspired by Zellij
28  - GPU rendering with automatic VA-API/VDPAU detection
29  - Built-in ad blocking (UBlock-based network + cosmetic filtering)
30  - Launcher integration (rofi/fuzzel) with favicons
31  - Search shortcuts via bangs (!g, !gi, etc.)
32  - Session management with auto-save and restore
33
34Use 'dumber browse' to launch the graphical browser, or explore the
35subcommands for CLI-based operations like history search and session
36management.`,
37		PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
38			// Skip initialization for commands that don't need app context
39			switch cmd.Name() {
40			case "help", "completion", "gen-docs":
41				return nil
42			}
43
44			var err error
45			app, err = cli.NewApp()
46			if err != nil {
47				return fmt.Errorf("initialize app: %w", err)
48			}
49			// Set build info from main.go
50			app.BuildInfo = buildInfo
51			return nil
52		},
53		PersistentPostRun: func(_ *cobra.Command, _ []string) {
54			if app != nil {
55				_ = app.Close()
56			}
57		},
58	}
59)
60
61// Execute runs the root command.
62func Execute() {
63	if err := rootCmd.Execute(); err != nil {
64		fmt.Fprintln(os.Stderr, err)
65		os.Exit(1)
66	}
67}
68
69// GetApp returns the initialized app (for use by subcommands).
70func GetApp() *cli.App {
71	return app
72}
73
74// browseCmd is a placeholder for help - actual execution is in main.go
75var browseCmd = &cobra.Command{
76	Use:   "browse [url]",
77	Short: "Launch the graphical browser",
78	Long: `Launch the GTK4 graphical browser.
79
80If a URL is provided, navigate to it. Otherwise, open the homepage.
81
82Examples:
83  dumber browse                  # Open browser to homepage
84  dumber browse example.com      # Open browser to URL`,
85	Run: func(_ *cobra.Command, _ []string) {
86		// This is handled by main.go before cobra runs
87	},
88}
89
90func init() {
91	rootCmd.AddCommand(browseCmd)
92}
93
94// SetBuildInfo sets the build information (called from main.go before Execute).
95func SetBuildInfo(info build.Info) {
96	buildInfo = info
97}

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