Skip to content

Commit 7e43d4d

Browse files
authored
Update main.go
1 parent 64aa569 commit 7e43d4d

File tree

1 file changed

+86
-65
lines changed

1 file changed

+86
-65
lines changed

hacker-help/main.go

Lines changed: 86 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,189 @@
11
package main
2+
23
import (
34
"fmt"
45
"os"
6+
57
"github.com/charmbracelet/bubbletea"
68
"github.com/charmbracelet/bubbles/key"
79
"github.com/charmbracelet/bubbles/list"
810
"github.com/charmbracelet/bubbles/viewport"
911
"github.com/charmbracelet/lipgloss"
1012
)
13+
1114
type Command struct {
12-
Name string
15+
Name string
1316
Description string
14-
Details string
17+
Details string
1518
}
19+
1620
var commands = []Command{
1721
{
18-
Name: "hacker unpack add-ons",
22+
Name: "hacker unpack add-ons",
1923
Description: "Install Wine, BoxBuddy, Winezgui, Gearlever",
20-
Details: "This command installs add-ons like Wine for running Windows applications, BoxBuddy for managing Flatpaks, Winezgui for Wine GUI, and Gearlever for additional utilities.",
24+
Details: "This command installs add-ons like Wine for running Windows applications, BoxBuddy for managing Flatpaks, Winezgui for Wine GUI, and Gearlever for additional utilities.",
2125
},
2226
{
23-
Name: "hacker unpack g-s",
27+
Name: "hacker unpack g-s",
2428
Description: "Install gaming and cybersecurity tools",
25-
Details: "Installs both gaming (Steam, Lutris, etc.) and cybersecurity tools (container with BlackArch).",
29+
Details: "Installs both gaming (Steam, Lutris, etc.) and cybersecurity tools (container with BlackArch).",
2630
},
2731
{
28-
Name: "hacker unpack devtools",
32+
Name: "hacker unpack devtools",
2933
Description: "Install Atom",
30-
Details: "Installs the Atom text editor via Flatpak for development purposes.",
34+
Details: "Installs the Atom text editor via Flatpak for development purposes.",
3135
},
3236
{
33-
Name: "hacker unpack emulators",
37+
Name: "hacker unpack emulators",
3438
Description: "Install PlayStation, Nintendo, DOSBox, PS3 emulators",
35-
Details: "Installs various emulators including shadPS4, Ryujinx, DOSBox-X, and RPCS3.",
39+
Details: "Installs various emulators including shadPS4, Ryujinx, DOSBox-X, and RPCS3.",
3640
},
3741
{
38-
Name: "hacker unpack cybersecurity",
42+
Name: "hacker unpack cybersecurity",
3943
Description: "Setup cybersecurity container with BlackArch",
40-
Details: "Creates a distrobox container with Arch Linux, installs BlackArch, enables multilib, and allows selecting categories or all tools.",
44+
Details: "Creates a distrobox container with Arch Linux, installs BlackArch, enables multilib, and allows selecting categories or all tools.",
4145
},
4246
{
43-
Name: "hacker unpack hacker-mode",
47+
Name: "hacker unpack hacker-mode",
4448
Description: "Install gamescope",
45-
Details: "Installs gamescope for advanced gaming session management.",
49+
Details: "Installs gamescope for advanced gaming session management.",
4650
},
4751
{
48-
Name: "hacker unpack select",
52+
Name: "hacker unpack select",
4953
Description: "Interactive package selection with TUI",
50-
Details: "Provides an interactive TUI to select categories or individual applications, with search capability.",
54+
Details: "Provides an interactive TUI to select categories or individual applications, with search capability.",
5155
},
5256
{
53-
Name: "hacker unpack gaming",
57+
Name: "hacker unpack gaming",
5458
Description: "Install OBS Studio, Lutris, Steam, etc.",
55-
Details: "Installs gaming tools including OBS Studio, Lutris, Steam, Heroic Games Launcher, Discord, and Roblox support.",
59+
Details: "Installs gaming tools including OBS Studio, Lutris, Steam, Heroic Games Launcher, Discord, and Roblox support.",
5660
},
5761
{
58-
Name: "hacker unpack noroblox",
62+
Name: "hacker unpack noroblox",
5963
Description: "Install gaming tools without Roblox",
60-
Details: "Installs gaming tools like the gaming command but excludes Roblox-related packages.",
64+
Details: "Installs gaming tools like the gaming command but excludes Roblox-related packages.",
6165
},
6266
{
63-
Name: "hacker help",
67+
Name: "hacker unpack gamescope-session-steam",
68+
Description: "Install and setup gamescope-session-steam",
69+
Details: "Checks and installs gamescope via apt, checks and installs Steam flatpak, clones the repo to /tmp, and runs unpack.hacker with hackerc.",
70+
},
71+
{
72+
Name: "hacker help",
6473
Description: "Display this help message",
65-
Details: "Launches this interactive help UI.",
74+
Details: "Launches this interactive help UI.",
6675
},
6776
{
68-
Name: "hacker install <package>",
77+
Name: "hacker install <package>",
6978
Description: "Install package using apt",
70-
Details: "Runs sudo apt install -y <package>.",
79+
Details: "Runs sudo apt install -y <package>.",
7180
},
7281
{
73-
Name: "hacker remove <package>",
82+
Name: "hacker remove <package>",
7483
Description: "Remove package using apt",
75-
Details: "Runs sudo apt remove -y <package>.",
84+
Details: "Runs sudo apt remove -y <package>.",
7685
},
7786
{
78-
Name: "hacker flatpak-install <package>",
87+
Name: "hacker flatpak-install <package>",
7988
Description: "Run flatpak install -y flathub <package>",
80-
Details: "Installs a Flatpak package from Flathub.",
89+
Details: "Installs a Flatpak package from Flathub.",
8190
},
8291
{
83-
Name: "hacker flatpak-remove <package>",
92+
Name: "hacker flatpak-remove <package>",
8493
Description: "Run flatpak remove -y <package>",
85-
Details: "Removes a Flatpak package.",
94+
Details: "Removes a Flatpak package.",
8695
},
8796
{
88-
Name: "hacker flatpak-update",
97+
Name: "hacker flatpak-update",
8998
Description: "Run flatpak update -y",
90-
Details: "Updates all installed Flatpak packages.",
99+
Details: "Updates all installed Flatpak packages.",
91100
},
92101
{
93-
Name: "hacker system logs",
102+
Name: "hacker system logs",
94103
Description: "Show system logs",
95-
Details: "Displays recent system logs using journalctl -xe.",
104+
Details: "Displays recent system logs using journalctl -xe.",
96105
},
97106
{
98-
Name: "hacker run update-system",
107+
Name: "hacker run update-system",
99108
Description: "Update the system",
100-
Details: "Runs the system update script.",
109+
Details: "Runs the system update script.",
101110
},
102111
{
103-
Name: "hacker run check-updates",
112+
Name: "hacker run check-updates",
104113
Description: "Check for system updates",
105-
Details: "Runs the update check notification script.",
114+
Details: "Runs the update check notification script.",
106115
},
107116
{
108-
Name: "hacker run steam",
117+
Name: "hacker run steam",
109118
Description: "Launch Steam via HackerOS script",
110-
Details: "Launches Steam using a custom HackerOS script.",
119+
Details: "Launches Steam using a custom HackerOS script.",
111120
},
112121
{
113-
Name: "hacker run hacker-launcher",
122+
Name: "hacker run hacker-launcher",
114123
Description: "Launch HackerOS Launcher",
115-
Details: "Runs the HackerOS application launcher.",
124+
Details: "Runs the HackerOS application launcher.",
116125
},
117126
{
118-
Name: "hacker run hackeros-game-mode",
127+
Name: "hacker run hackeros-game-mode",
119128
Description: "Run HackerOS Game Mode",
120-
Details: "Launches the HackerOS Game Mode AppImage.",
129+
Details: "Launches the HackerOS Game Mode AppImage.",
121130
},
122131
{
123-
Name: "hacker run update-hackeros",
132+
Name: "hacker run update-hackeros",
124133
Description: "Update HackerOS",
125-
Details: "Runs the update-hackeros.sh script to update HackerOS.",
134+
Details: "Runs the update-hackeros.sh script to update HackerOS.",
126135
},
127136
{
128-
Name: "hacker update",
137+
Name: "hacker update",
129138
Description: "Perform system update (apt, flatpak, snap, firmware, omz)",
130-
Details: "Updates APT, Flatpak, Snap, firmware, and Oh-My-Zsh.",
139+
Details: "Updates APT, Flatpak, Snap, firmware, and Oh-My-Zsh.",
131140
},
132141
{
133-
Name: "hacker game",
142+
Name: "hacker game",
134143
Description: "Play a fun Hacker Adventure game",
135-
Details: "Starts an interactive text-based adventure game in the terminal with expanded levels and challenges.",
144+
Details: "Starts an interactive text-based adventure game in the terminal with expanded levels and challenges.",
136145
},
137146
{
138-
Name: "hacker hacker-lang",
147+
Name: "hacker hacker-lang",
139148
Description: "Information about Hacker programming language",
140-
Details: "Displays info about using the .hacker file extension and hackerc compiler.",
149+
Details: "Displays info about using the .hacker file extension and hackerc compiler.",
141150
},
142151
{
143-
Name: "hacker ascii",
152+
Name: "hacker ascii",
144153
Description: "Display HackerOS ASCII art",
145-
Details: "Shows the HackerOS ASCII art from the config file.",
154+
Details: "Shows the HackerOS ASCII art from the config file.",
146155
},
147156
{
148-
Name: "hacker enter <container>",
157+
Name: "hacker enter <container>",
149158
Description: "Enter a distrobox container",
150-
Details: "Runs distrobox enter <container> to access the container shell.",
159+
Details: "Runs distrobox enter <container> to access the container shell.",
151160
},
152161
{
153-
Name: "hacker remove-container <container>",
162+
Name: "hacker remove-container <container>",
154163
Description: "Remove a distrobox container",
155-
Details: "Stops and removes the specified distrobox container after confirmation.",
164+
Details: "Stops and removes the specified distrobox container after confirmation.",
156165
},
157166
}
167+
158168
type item struct {
159169
cmd Command
160170
}
161-
func (i item) Title() string { return i.cmd.Name }
171+
172+
func (i item) Title() string { return i.cmd.Name }
162173
func (i item) Description() string { return i.cmd.Description }
163174
func (i item) FilterValue() string { return i.cmd.Name + " " + i.cmd.Description }
175+
164176
type mode int
177+
165178
const (
166179
listMode mode = iota
167180
detailsMode
168181
)
182+
169183
type keyMap struct {
170184
quit key.Binding
171185
}
186+
172187
func newKeyMap() *keyMap {
173188
return &keyMap{
174189
quit: key.NewBinding(
@@ -177,14 +192,16 @@ func newKeyMap() *keyMap {
177192
),
178193
}
179194
}
195+
180196
type model struct {
181-
list list.Model
197+
list list.Model
182198
viewport viewport.Model
183-
keys *keyMap
184-
ready bool
185-
mode mode
199+
keys *keyMap
200+
ready bool
201+
mode mode
186202
selected int
187203
}
204+
188205
func newModel() model {
189206
var items []list.Item
190207
items = append(items, item{Command{Name: "Exit", Description: "Press to exit"}})
@@ -202,14 +219,16 @@ func newModel() model {
202219
vp := viewport.New(0, 0)
203220
vp.Style = lipgloss.NewStyle().Border(lipgloss.NormalBorder(), true).Padding(1)
204221
return model{
205-
list: l,
222+
list: l,
206223
viewport: vp,
207-
keys: newKeyMap(),
224+
keys: newKeyMap(),
208225
}
209226
}
227+
210228
func (m model) Init() tea.Cmd {
211229
return nil
212230
}
231+
213232
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
214233
var cmd tea.Cmd
215234
switch msg := msg.(type) {
@@ -253,6 +272,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
253272
}
254273
return m, cmd
255274
}
275+
256276
func (m model) View() string {
257277
if !m.ready {
258278
return "Initializing..."
@@ -273,6 +293,7 @@ func (m model) View() string {
273293
Render(rightContent)
274294
return lipgloss.JoinHorizontal(lipgloss.Top, left, right)
275295
}
296+
276297
func main() {
277298
p := tea.NewProgram(newModel(), tea.WithAltScreen())
278299
if _, err := p.Run(); err != nil {

0 commit comments

Comments
 (0)