flatface.go: refined updating feature, added intructions to menus

This commit is contained in:
mollusk 2018-01-02 23:37:32 -07:00
parent fd3e8a507f
commit 099312acce

View File

@ -21,42 +21,81 @@ func input(s string) (string, error) {
} }
func searchRepo() { func searchRepo() {
var programName, _ = input("Name of search: ") print("\n| Search Repositories |\n\n")
cmd := exec.Command("flatpak", "search", programName) print("Enter a search term and copy the namespace to clipboard\n")
out, err := cmd.CombinedOutput() print("Paste this later to the install menu.\n\n")
if err != nil { print("Type: 'menu' for main menu\n")
log.Fatalf("cmd.Run() failed with %s\n", err) print("Type: 'q' to quit the application\n\n")
var programName, _ = input(">> ")
if programName == "menu" {
return
} else if programName == "q" {
os.Exit(0)
} else {
cmd := exec.Command("flatpak", "search", programName)
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err)
}
fmt.Print("\n", "Results for ", programName, ": \n\n", string(out), "\n")
} }
fmt.Print("\n", "Results for ", programName, ": \n\n", string(out), "\n")
} }
func installPak() { func installPak() {
var programName, _ = input("Install: ") print("\n| Install Menu |\n\n")
cmd := exec.Command("flatpak", "install", "flathub", programName) print("To Use: Copy paste a flatpak namespace from search results\n\n")
out, err := cmd.CombinedOutput() print("EXAMPLE: 'com.play0ad.zeroad' - installs the Game '0ad'\n\n")
if err != nil { print("Type: 'menu' for main menu\n")
log.Fatalf("cmd.Run() failed with %s\n", err) print("Type: 'q' to quit the application\n\n")
} print("NOTE: install can take several seconds and appear to hang. Please be patient...\n\n")
fmt.Print("\n", "Results for ", programName, ": \n\n", string(out), "\n") var programName, _ = input(">> ")
}
func removePak() { if programName == "menu" {
var programName, _ = input("Uninstall: ") return
cmd := exec.Command("flatpak", "uninstall", programName) } else if programName == "q" {
out, err := cmd.CombinedOutput() os.Exit(0)
if err != nil { } else {
log.Fatalf("cmd.Run() failed with %s\n", err) cmd := exec.Command("flatpak", "install", "flathub", programName)
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err)
}
fmt.Print(string(out), "\n")
} }
fmt.Print("\n", "Results for ", programName, ": \n\n", string(out), "\n\n")
} }
func listPak() { func listPak() {
print("\n| List of installed Flatpaks |\n\n")
cmd := exec.Command("flatpak", "list") cmd := exec.Command("flatpak", "list")
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
if err != nil { if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err) log.Fatalf("cmd.Run() failed with %s\n", err)
} }
fmt.Print("\n", "Results for ", ": \n\n", string(out), "\n\n") fmt.Print(string(out), "\n\n")
}
func removePak() {
print("\n| Uninstall Flatpaks |\n\n")
listPak()
print("\n\nCopy and paste a namespace above and press enter to uninstall\n\n")
print("Type: 'menu' for main menu\n")
print("Type: 'q' to quit the application\n\n")
var programName, _ = input(">> ")
if programName == "menu" {
return
} else if programName == "q" {
os.Exit(0)
} else {
cmd := exec.Command("flatpak", "uninstall", programName)
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err)
}
fmt.Print(string(out), "\n\n")
}
} }
//// TODO //// TODO
@ -73,7 +112,8 @@ func optionsMenu() {
} }
} }
*/ */
func updatePak() { func syncRepo() {
print("Syncing repo data...\n")
cmd := exec.Command("flatpak", "update", "--appstream") cmd := exec.Command("flatpak", "update", "--appstream")
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
if err != nil { if err != nil {
@ -83,10 +123,20 @@ func updatePak() {
} }
func checkRepo() { func checkRepo() {
print("\nSyncing repos...\n") print("\nAdding flathub repo if needed...\n")
cmd := exec.Command("flatpak", "remote-add", "--if-not-exists", "flathub", "https://flathub.org/repo/flathub.flatpakrepo") cmd := exec.Command("flatpak", "remote-add", "--if-not-exists", "flathub", "https://flathub.org/repo/flathub.flatpakrepo")
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
updatePak() syncRepo()
if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err)
}
fmt.Print(string(out))
}
func updatePak() {
print("Checking for app upgrades..\n")
cmd := exec.Command("flatpak", "update")
out, err := cmd.CombinedOutput()
if err != nil { if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err) log.Fatalf("cmd.Run() failed with %s\n", err)
} }
@ -116,7 +166,7 @@ func mainMenu() {
} else if choice == "5" { } else if choice == "5" {
updatePak() updatePak()
} else if choice == "q" { } else if choice == "q" {
os.Exit(1) os.Exit(0)
} else { } else {
print("Unknown option") print("Unknown option")
} }