馃Ч Dependency Scanner and Pruner
go
dependency
dependencies
1package main
2
3import (
4 "fmt"
5 tea "github.com/charmbracelet/bubbletea"
6 "os"
7 "path/filepath"
8)
9
10func main() {
11 rootPath, pathError := resolveRootPath()
12
13 if pathError != nil {
14 fmt.Fprintf(os.Stderr, "error: %s\n", pathError)
15 os.Exit(1)
16 }
17
18 finalModel, runError := tea.NewProgram(
19 initialModel(rootPath),
20 tea.WithAltScreen(),
21 ).Run()
22
23 if runError != nil {
24 fmt.Fprintf(os.Stderr, "error: %s\n", runError)
25 os.Exit(1)
26 }
27
28 if model, isApplicationModel := finalModel.(applicationModel); isApplicationModel {
29 if model.scanError != nil {
30 fmt.Fprintf(os.Stderr, "error: %s\n", model.scanError)
31 os.Exit(1)
32 }
33
34 if model.deletedCount > 0 {
35 fmt.Printf("deleted %d directories, freed %s\n", model.deletedCount, formatBytes(model.freedBytes))
36 }
37 }
38}
39
40func resolveRootPath() (string, error) {
41 if len(os.Args) > 1 {
42 return filepath.Abs(os.Args[1])
43 }
44
45 return os.Getwd()
46}