diff --git a/fallbackui.go b/fallbackui.go deleted file mode 100644 index 8d29e6d..0000000 --- a/fallbackui.go +++ /dev/null @@ -1,68 +0,0 @@ -package main - -import ( - "fmt" - "strconv" -) - -func createFallbackUI() { - var choice string - paths, names := getProfilePaths() - - 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") - - message, err := install(profile, uuids, theme) - if err != nil { - fmt.Printf("%s: %s", message, err.Error()) - fmt.Scanln() - return - } - - fmt.Print("\nShadowFox was successfully installed! (Press 'enter' to exit)") - fmt.Scanln() - return -} diff --git a/main.go b/main.go index b2713a5..13f493a 100644 --- a/main.go +++ b/main.go @@ -2,24 +2,12 @@ package main import ( "os" - - "github.com/gen2brain/dlgs" ) -func checkErr(msg string, err error) { - if err != nil { - dlgs.Error("Shadowfox Updater", msg+"\n"+err.Error()) - panic(err) - } -} - func main() { if len(os.Args) > 1 { cli() } else { - err := createUI() - if err != nil { - createFallbackUI() - } + createUI() } } diff --git a/ui.go b/ui.go index 5747749..cc50946 100644 --- a/ui.go +++ b/ui.go @@ -4,14 +4,21 @@ import ( "github.com/gen2brain/dlgs" ) -func createUI() error { +func checkErr(msg string, err error) { + if err != nil { + dlgs.Error("Shadowfox Updater", msg+"\n"+err.Error()) + panic(err) + } +} + +func createUI() { paths, names := getProfilePaths() name, selected, err := dlgs.List("Shadowfox Updater", "Which Firefox profile are you going to use?", names) checkErr("", err) if !selected { dlgs.Info("Shadowfox Updater", "You didn't pick any profile, the application will now close.") - return nil + return } pathIndex := 0 @@ -27,7 +34,7 @@ func createUI() error { checkErr("", err) if !selected { dlgs.Info("Shadowfox Updater", "You didn't pick any action, the application will now close.") - return nil + return } if action == "Install/Update Shadowfox" { @@ -51,5 +58,4 @@ func createUI() error { checkErr(msg, err) } } - return nil }