-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
766 lines (647 loc) · 20.3 KB
/
main.go
File metadata and controls
766 lines (647 loc) · 20.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
package main
import (
"flag"
"fmt"
"io/fs"
"os"
"path/filepath"
"sort"
"strings"
"time"
"github.com/charmbracelet/bubbles/progress"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
// SafetyLevel represents how safe it is to remove a directory
type SafetyLevel int
const (
Safe SafetyLevel = iota
Moderate
Risky
)
func (s SafetyLevel) String() string {
switch s {
case Safe:
return "SAFE"
case Moderate:
return "MODERATE"
case Risky:
return "RISKY"
default:
return "UNKNOWN"
}
}
func (s SafetyLevel) Color() lipgloss.Color {
switch s {
case Safe:
return lipgloss.Color("2")
case Moderate:
return lipgloss.Color("3")
case Risky:
return lipgloss.Color("1")
default:
return lipgloss.Color("8")
}
}
// DevDirectory represents a development output directory
type DevDirectory struct {
Path string
Description string
Safety SafetyLevel
Size int64
}
// Common development directories to scan for
var commonDevDirs = map[string]DevDirectory{
// Very safe - these are clearly build artifacts/dependencies
"node_modules": {Description: "Node.js dependencies", Safety: Safe},
"target": {Description: "Maven/Cargo build output", Safety: Safe},
"__pycache__": {Description: "Python bytecode cache", Safety: Safe},
".pytest_cache": {Description: "Pytest cache", Safety: Safe},
".tox": {Description: "Tox testing cache", Safety: Safe},
"DerivedData": {Description: "Xcode derived data", Safety: Safe},
".next": {Description: "Next.js build cache", Safety: Safe},
".nuxt": {Description: "Nuxt.js build cache", Safety: Safe},
".gradle": {Description: "Gradle cache", Safety: Safe},
".pub-cache": {Description: "Dart/Flutter pub cache", Safety: Safe},
".flutter-plugins": {Description: "Flutter plugins cache", Safety: Safe},
"coverage": {Description: "Test coverage reports", Safety: Safe},
"tmp": {Description: "Temporary files", Safety: Safe},
"temp": {Description: "Temporary files", Safety: Safe},
".cache": {Description: "Hidden cache directory", Safety: Safe},
"obj": {Description: "Object files", Safety: Safe},
"intermediate": {Description: "Intermediate build files", Safety: Safe},
"android/build": {Description: "Android build output", Safety: Safe},
// Moderate safety - could contain important files
"dist": {Description: "Distribution/build output", Safety: Moderate},
"build": {Description: "Build output", Safety: Moderate},
"out": {Description: "Output directory", Safety: Moderate},
"bin": {Description: "Binary output", Safety: Moderate},
"release": {Description: "Release builds", Safety: Moderate},
"debug": {Description: "Debug builds", Safety: Moderate},
"logs": {Description: "Log files", Safety: Moderate},
"cache": {Description: "Cache directory", Safety: Moderate},
"Pods": {Description: "CocoaPods dependencies", Safety: Moderate},
"lib": {Description: "Library files", Safety: Moderate},
"generated": {Description: "Generated code", Safety: Moderate},
"artifacts": {Description: "Build artifacts", Safety: Moderate},
"output": {Description: "Build output", Safety: Moderate},
".m2": {Description: "Maven local repository", Safety: Moderate},
"packages": {Description: "Package cache", Safety: Moderate},
"ios/Pods": {Description: "iOS CocoaPods", Safety: Moderate},
// Risky - version control and important dependencies
"vendor": {Description: "Vendor dependencies", Safety: Risky},
".git": {Description: "Git repository", Safety: Risky},
".svn": {Description: "SVN repository", Safety: Risky},
}
type model struct {
directories []DevDirectory
cursor int
selected map[int]bool
scanning bool
scanPath string
progress progress.Model
scanProgress float64
scannedDirs int
showConfirmation bool
pendingAction string // "delete" or "deleteAll"
width int
height int
showSplash bool
viewportStart int
}
func (m model) Init() tea.Cmd {
return tea.Batch(
scanDirectories(m.scanPath),
tickProgress(),
)
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
switch msg := msg.(type) {
case tea.WindowSizeMsg:
m.width = msg.Width
m.height = msg.Height
case tea.KeyMsg:
if m.showConfirmation {
switch msg.String() {
case "y", "Y":
m.showConfirmation = false
if m.pendingAction == "delete" || m.pendingAction == "deleteAll" {
return m, deleteSelected(m.directories, m.selected)
}
case "n", "N", "esc":
m.showConfirmation = false
m.pendingAction = ""
}
return m, nil
}
switch msg.String() {
case "esc", "q", "ctrl+c":
return m, tea.Quit
case "up", "k":
if m.cursor > 0 {
m.cursor--
m.adjustViewport()
}
case "down", "j":
if m.cursor < len(m.directories)-1 {
m.cursor++
m.adjustViewport()
}
case "enter", " ":
if m.cursor < len(m.directories) {
m.selected[m.cursor] = !m.selected[m.cursor]
// Move cursor down after selecting
if m.cursor < len(m.directories)-1 {
m.cursor++
m.adjustViewport()
}
}
return m, nil
case "d":
m.showConfirmation = true
m.pendingAction = "delete"
case "D":
for i := range m.directories {
if m.directories[i].Safety == Safe {
m.selected[i] = true
}
}
m.showConfirmation = true
m.pendingAction = "deleteAll"
case "r":
m.scanning = true
return m, scanDirectories(m.scanPath)
}
case scanCompleteMsg:
m.directories = msg.directories
sort.Slice(m.directories, func(i, j int) bool {
return m.directories[i].Safety < m.directories[j].Safety
})
m.scanning = false
m.scanProgress = 1.0
m.showSplash = false
case scanProgressMsg:
m.scanProgress = msg.progress
m.scannedDirs = msg.scannedDirs
case progressTickMsg:
if m.scanning && m.scanProgress < 1.0 {
m.scanProgress += 0.02
if m.scanProgress > 1.0 {
m.scanProgress = 1.0
}
m.scannedDirs += 50
return m, tickProgress()
}
case deleteCompleteMsg:
m.scanning = true
m.selected = make(map[int]bool)
m.cursor = 0
return m, scanDirectories(m.scanPath)
}
return m, cmd
}
func (m *model) adjustViewport() {
visibleRows := m.height - 18 // Match the visible rows calculation in renderMain
if visibleRows < 3 {
visibleRows = 3
}
if m.cursor < m.viewportStart {
m.viewportStart = m.cursor
} else if m.cursor >= m.viewportStart+visibleRows {
m.viewportStart = m.cursor - visibleRows + 1
}
}
func (m model) View() string {
if m.showSplash {
return m.renderSplash()
}
if m.scanning {
return m.renderScanning()
}
if m.showConfirmation {
return m.renderConfirmation()
}
return m.renderMain()
}
func (m model) renderSplash() string {
artStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("45")).
Bold(true)
scanningStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("6")).
Bold(true)
progressView := m.progress.ViewAs(m.scanProgress)
statusText := fmt.Sprintf("Scanning %s", m.scanPath)
content := artStyle.Render(splashArt) + "\n" + scanningStyle.Render(statusText) + "\n\n" + progressView
outerStyle := lipgloss.NewStyle().
BorderStyle(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("240")).
Padding(1).
Margin(1)
return outerStyle.Render(content)
}
func (m model) renderScanning() string {
scanningStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("6")).
Bold(true)
progressView := m.progress.ViewAs(m.scanProgress)
statusText := fmt.Sprintf("SCANNING %s\nDirectories scanned: %d", m.scanPath, m.scannedDirs)
content := scanningStyle.Render(statusText) + "\n\n" + progressView + "\n\nPress 'q' to quit"
outerStyle := lipgloss.NewStyle().
BorderStyle(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("240")).
Padding(1).
Margin(1)
return outerStyle.Render(content)
}
func (m model) renderMain() string {
var b strings.Builder
// Calculate available width
contentWidth := m.width - 6 // Account for border and padding
if contentWidth < 80 {
contentWidth = 80
}
// Header
headerStyle := lipgloss.NewStyle().
Bold(true).
Foreground(lipgloss.Color("15"))
// Column widths
selectWidth := 8
pathWidth := int(float64(contentWidth-selectWidth-12-12) * 0.65) // 65% of remaining (more for paths)
descWidth := int(float64(contentWidth-selectWidth-12-12) * 0.15) // 15% of remaining (much narrower)
safetyWidth := 12
sizeWidth := 12
header := fmt.Sprintf("%-*s %-*s %-*s %-*s %-*s",
selectWidth, "Select",
pathWidth, "Path",
descWidth, "Description",
safetyWidth, "Safety",
sizeWidth, "Size")
b.WriteString(headerStyle.Render(header))
b.WriteString("\n")
// Calculate visible rows based on available space
// Account for: border (2), padding (2), header (1), blank line (1), status (2), blank line (1), controls (9)
// Total overhead: ~18 lines
visibleRows := m.height - 18
if visibleRows < 3 {
visibleRows = 3
}
end := m.viewportStart + visibleRows
if end > len(m.directories) {
end = len(m.directories)
}
// Rows
for i := m.viewportStart; i < end; i++ {
b.WriteString(m.renderRow(i, selectWidth, pathWidth, descWidth, safetyWidth, sizeWidth, contentWidth))
b.WriteString("\n")
}
// Fill remaining space with empty lines to maintain consistent height
rowsDisplayed := end - m.viewportStart
if rowsDisplayed < visibleRows {
for i := rowsDisplayed; i < visibleRows; i++ {
b.WriteString(strings.Repeat(" ", contentWidth))
b.WriteString("\n")
}
}
// Status
totalSelected := 0
totalSize := int64(0)
for idx := range m.directories {
if m.selected[idx] {
totalSelected++
totalSize += m.directories[idx].Size
}
}
statusStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("241"))
b.WriteString("\n")
b.WriteString(statusStyle.Render(fmt.Sprintf("Selected: %d directories (%s)", totalSelected, formatSize(totalSize))))
b.WriteString("\n\n")
// Help - use multiple lines
b.WriteString(statusStyle.Render("Controls:"))
b.WriteString("\n")
b.WriteString(statusStyle.Render("\tk or up arrow: go up"))
b.WriteString("\n")
b.WriteString(statusStyle.Render("\tj or down arrow: go down"))
b.WriteString("\n")
b.WriteString(statusStyle.Render("\tspace/enter: toggle selection"))
b.WriteString("\n")
b.WriteString(statusStyle.Render("\td: delete selected"))
b.WriteString("\n")
b.WriteString(statusStyle.Render("\tD: auto-delete SAFE tagged folders"))
b.WriteString("\n")
b.WriteString(statusStyle.Render("\tr: refresh scan"))
b.WriteString("\n")
b.WriteString(statusStyle.Render("\tq: quit"))
outerStyle := lipgloss.NewStyle().
BorderStyle(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("240")).
Padding(1).
Width(m.width - 2)
return outerStyle.Render(b.String())
}
func (m model) renderRow(idx, selectWidth, pathWidth, descWidth, safetyWidth, sizeWidth, totalWidth int) string {
dir := m.directories[idx]
checkbox := "[ ]"
if m.selected[idx] {
checkbox = "[X]"
}
path := convertToTildePath(dir.Path)
// Extract the matched pattern (last directory component)
matchedPattern := filepath.Base(dir.Path)
// Truncate path if needed
if len(path) > pathWidth {
path = "..." + path[len(path)-(pathWidth-3):]
}
desc := dir.Description
if len(desc) > descWidth {
desc = desc[:descWidth-3] + "..."
}
safetyText := dir.Safety.String()
size := formatSize(dir.Size)
// Build row with plain text and proper spacing
row := fmt.Sprintf("%-*s %-*s %-*s %-*s %-*s",
selectWidth, checkbox,
pathWidth, path,
descWidth, desc,
safetyWidth, safetyText,
sizeWidth, size)
// Pad to full width
if len(row) < totalWidth {
row = row + strings.Repeat(" ", totalWidth-len(row))
}
if idx == m.cursor {
cursorStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("229")).
Background(lipgloss.Color("57"))
return cursorStyle.Render(row)
}
// For non-cursor rows, apply color to safety column and highlight matched pattern in red
safetyStyle := lipgloss.NewStyle().
Foreground(dir.Safety.Color()).
Bold(true)
redStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("196")).
Bold(true)
// Highlight the matched pattern in the path
pathWithHighlight := path
if strings.Contains(path, matchedPattern) {
// Find the last occurrence of the pattern in the displayed path
idx := strings.LastIndex(path, matchedPattern)
if idx != -1 {
before := path[:idx]
pattern := path[idx : idx+len(matchedPattern)]
after := path[idx+len(matchedPattern):]
pathWithHighlight = before + redStyle.Render(pattern) + after
}
}
// Build the row manually with styled safety and highlighted path
prefix := fmt.Sprintf("%-*s ", selectWidth, checkbox)
// Calculate spacing for path - we need to account for the actual display width
pathSpacing := strings.Repeat(" ", pathWidth-len(path))
styledSafety := safetyStyle.Render(fmt.Sprintf("%-*s", safetyWidth, safetyText))
suffix := fmt.Sprintf(" %-*s", sizeWidth, size)
// Calculate padding based on plain text length (without ANSI codes)
plainRowLen := selectWidth + 1 + pathWidth + 1 + descWidth + 1 + safetyWidth + 1 + sizeWidth
padding := ""
if totalWidth > plainRowLen {
padding = strings.Repeat(" ", totalWidth-plainRowLen)
}
return prefix + pathWithHighlight + pathSpacing + " " + fmt.Sprintf("%-*s ", descWidth, desc) + styledSafety + suffix + padding
}
func (m model) renderConfirmation() string {
totalSelected := 0
totalSize := int64(0)
for idx := range m.directories {
if m.selected[idx] {
totalSelected++
totalSize += m.directories[idx].Size
}
}
dangerStyle := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("196")).
Background(lipgloss.Color("52")).
Foreground(lipgloss.Color("255")).
Bold(true).
Padding(1, 2).
Width(60).
Align(lipgloss.Center)
warningStyle := lipgloss.NewStyle().
Foreground(lipgloss.Color("196")).
Bold(true)
var message string
if m.pendingAction == "deleteAll" {
safeCount := 0
for idx := range m.directories {
if m.selected[idx] && m.directories[idx].Safety == Safe {
safeCount++
}
}
message = fmt.Sprintf(
"%s\n\nYou are about to DELETE %d SAFE directories!\nThis will permanently remove %s of data.\n\n%s\n\nType 'y' to confirm, 'n' to cancel",
warningStyle.Render("⚠ BULK DELETE CONFIRMATION ⚠"),
safeCount,
formatSize(totalSize),
warningStyle.Render("THIS ACTION CANNOT BE UNDONE!"),
)
} else {
message = fmt.Sprintf(
"%s\n\nYou are about to DELETE %d selected directories!\nThis will permanently remove %s of data.\n\n%s\n\nType 'y' to confirm, 'n' to cancel",
warningStyle.Render("⚠ DELETE CONFIRMATION ⚠"),
totalSelected,
formatSize(totalSize),
warningStyle.Render("THIS ACTION CANNOT BE UNDONE!"),
)
}
confirmDialog := dangerStyle.Render(message)
width := m.width
height := m.height
if width == 0 {
width = 80
}
if height == 0 {
height = 24
}
return lipgloss.Place(width, height, lipgloss.Center, lipgloss.Center, confirmDialog, lipgloss.WithWhitespaceForeground(lipgloss.Color("240")))
}
type scanCompleteMsg struct {
directories []DevDirectory
}
type scanProgressMsg struct {
progress float64
scannedDirs int
}
type progressTickMsg struct{}
type deleteCompleteMsg struct{}
func tickProgress() tea.Cmd {
return tea.Tick(100*time.Millisecond, func(time.Time) tea.Msg {
return progressTickMsg{}
})
}
func scanDirectories(rootPath string) tea.Cmd {
return func() tea.Msg {
var foundDirs []DevDirectory
resolvedRoot, err := filepath.EvalSymlinks(rootPath)
if err != nil {
resolvedRoot = rootPath
}
err = filepath.Walk(resolvedRoot, func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
if info.Mode()&os.ModeSymlink != 0 {
realPath, err := filepath.EvalSymlinks(path)
if err != nil {
return nil
}
realInfo, err := os.Stat(realPath)
if err != nil {
return nil
}
info = realInfo
}
if !info.IsDir() {
return nil
}
dirName := filepath.Base(path)
if template, exists := commonDevDirs[dirName]; exists {
size := calculateDirSize(path)
foundDir := DevDirectory{
Path: path,
Description: template.Description,
Safety: template.Safety,
Size: size,
}
foundDirs = append(foundDirs, foundDir)
}
return nil
})
if err != nil {
return scanCompleteMsg{directories: []DevDirectory{}}
}
return scanCompleteMsg{directories: foundDirs}
}
}
func deleteSelected(directories []DevDirectory, selected map[int]bool) tea.Cmd {
return func() tea.Msg {
for idx, dir := range directories {
if selected[idx] {
os.RemoveAll(dir.Path)
}
}
return deleteCompleteMsg{}
}
}
func calculateDirSize(path string) int64 {
var size int64
done := make(chan bool, 1)
go func() {
filepath.WalkDir(path, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return nil
}
if !d.IsDir() {
if info, err := d.Info(); err == nil {
size += info.Size()
}
}
return nil
})
done <- true
}()
select {
case <-done:
return size
case <-time.After(2 * time.Second):
return -1
}
}
func formatSize(bytes int64) string {
if bytes < 0 {
return "calculating..."
}
const unit = 1024
if bytes < unit {
return fmt.Sprintf("%d B", bytes)
}
div, exp := int64(unit), 0
for n := bytes / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %cB", float64(bytes)/float64(div), "KMGTPE"[exp])
}
func convertToTildePath(absPath string) string {
homeDir, err := os.UserHomeDir()
if err != nil {
return absPath
}
if strings.HasPrefix(absPath, homeDir) {
return "~" + absPath[len(homeDir):]
}
return absPath
}
const splashArt = `
██████████ █████████ ████
░░███░░░░███ ███░░░░░███░░███
░███ ░░███ ██████ █████ █████ ███ ░░░ ░███ ██████ ██████ ████████
░███ ░███ ███░░███░░███ ░░███ ░███ ░███ ███░░███ ░░░░░███ ░░███░░███
░███ ░███░███████ ░███ ░███ ░███ ░███ ░███████ ███████ ░███ ░███
░███ ███ ░███░░░ ░░███ ███ ░░███ ███ ░███ ░███░░░ ███░░███ ░███ ░███
██████████ ░░██████ ░░█████ ░░█████████ █████░░██████ ░░████████ ████ █████
░░░░░░░░░░ ░░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░░ ░░░░░░░░ ░░░░ ░░░░░
`
const version = "v0.1.1"
const helpText = `DevClean: Code Cleanup, Simplified.
Usage:
devclean [path]
Flags:
--version Show version information
--help Show this help message
If a path is not provided, it will scan the current directory.
`
func main() {
versionFlag := flag.Bool("version", false, "Print version information")
helpFlag := flag.Bool("help", false, "Print help information")
flag.Parse()
if *versionFlag {
fmt.Println("DevClean", version)
os.Exit(0)
}
if *helpFlag {
fmt.Println(helpText)
os.Exit(0)
}
scanPath := "."
if flag.NArg() > 0 {
scanPath = flag.Arg(0)
}
absPath, err := filepath.Abs(scanPath)
if err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
prog := progress.New(progress.WithDefaultGradient())
prog.Width = 50
m := model{
directories: []DevDirectory{},
cursor: 0,
selected: make(map[int]bool),
scanning: true,
scanPath: absPath,
progress: prog,
scanProgress: 0.0,
showConfirmation: false,
pendingAction: "",
width: 80,
height: 24,
showSplash: true,
viewportStart: 0,
}
if _, err := tea.NewProgram(m, tea.WithAltScreen()).Run(); err != nil {
fmt.Printf("Error running program: %v", err)
os.Exit(1)
}
}