-
Notifications
You must be signed in to change notification settings - Fork 16
/
fallback.go
94 lines (78 loc) · 2.13 KB
/
fallback.go
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
package main
import (
"fmt"
"strconv"
"github.com/skratchdot/open-golang/open"
)
func createFallbackUI() {
fmt.Println(header)
shouldUpdate, newTag, err := checkForUpdate()
if err != nil {
fmt.Println(err.Error())
fmt.Scanln()
panic(err)
}
if shouldUpdate {
var choice string
fmt.Printf("There is a new shadowfox-updater version available (%s -> %s)\nDo you want to update? [y/n]", tag, newTag)
fmt.Scanln(&choice)
wantToUpdate := (choice == "y" || choice == "Y")
if wantToUpdate {
open.Start("https://github.com/SrKomodo/shadowfox-updater/#installing")
}
}
var choice string
paths, names, err := getProfilePaths()
if err != nil {
fmt.Println(err.Error())
fmt.Scanln()
panic(err)
}
if paths == nil {
fmt.Println("ShadowFox couldn't automatically find 'profiles.ini'. Please follow these steps:")
fmt.Println(" 1. Close the program")
fmt.Println(" 2. Move the program to the folder 'profiles.ini' is located")
fmt.Println(" 3. Run the program")
fmt.Scanln()
return
}
fmt.Println("Available profiles:")
for i, name := range names {
fmt.Printf(" %d: %s\n", i, name)
}
fmt.Printf("\nWhich one would you like to use? [%d-%d] ", 0, len(names)-1)
var profile string
for {
fmt.Scanln(&choice)
i, err := strconv.Atoi(choice)
if err != nil || i < 0 || i > len(paths) {
fmt.Print("Please input a valid number ")
} else {
profile = paths[i]
break
}
}
fmt.Print("\nDo you want to (1) install or (2) uninstall ShadowFox? [1/2] ")
fmt.Scanln(&choice)
if choice == "2" {
uninstall(profile)
fmt.Print("\nShadowFox was successfully uninstalled! (Press 'enter' to exit)")
fmt.Scanln()
return
}
fmt.Print("\nWould you like to auto-generate UUIDs? [y/n] ")
fmt.Scanln(&choice)
uuids := (choice == "y" || choice == "Y")
fmt.Print("\nWould you like to automatically set the Firefox dark theme? [y/n] ")
fmt.Scanln(&choice)
theme := (choice == "y" || choice == "Y")
err = install(profile, uuids, theme)
if err != nil {
fmt.Println(err.Error())
fmt.Scanln()
panic(err)
}
fmt.Print("\nShadowFox was successfully installed! (Press 'enter' to exit)")
fmt.Scanln()
return
}