-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
72 lines (62 loc) · 1.39 KB
/
main.go
File metadata and controls
72 lines (62 loc) · 1.39 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
package main
import (
"fmt"
"os"
"appy/appimage"
)
func main() {
if len(os.Args) != 2 {
printUsage()
os.Exit(1)
}
if handleOption(os.Args[1]) {
return
}
appImagePath := os.Args[1]
// Check if file exists
if _, err := os.Stat(appImagePath); os.IsNotExist(err) {
fmt.Printf("Error: File not found: %s\n", appImagePath)
os.Exit(1)
}
// Parse AppImage
metadata, err := appimage.Parse(appImagePath)
if err != nil {
// Show error in GUI
showError(err)
os.Exit(1)
}
// Show metadata in GUI
showMainWindow(metadata)
}
func handleOption(arg string) bool {
switch arg {
case "--install":
if err := installAppy(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
fmt.Println("Appy installed successfully")
return true
case "--uninstall":
if err := uninstallAppy(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
fmt.Println("Appy uninstalled successfully")
return true
case "--help", "-h":
printUsage()
return true
}
return false
}
func printUsage() {
fmt.Println("Usage: appy <path-to-appimage>")
fmt.Println(" appy --install")
fmt.Println(" appy --uninstall")
fmt.Println("\nOptions:")
fmt.Println(" --install Install appy as default AppImage handler")
fmt.Println(" --uninstall Remove appy installation")
fmt.Println("\nExample:")
fmt.Println(" appy ~/Downloads/MyApp.AppImage")
}