flatface.go: refined updating feature, added intructions to menus
This commit is contained in:
parent
fd3e8a507f
commit
099312acce
84
flatface.go
84
flatface.go
@ -21,42 +21,81 @@ func input(s string) (string, error) {
|
||||
}
|
||||
|
||||
func searchRepo() {
|
||||
var programName, _ = input("Name of search: ")
|
||||
print("\n| Search Repositories |\n\n")
|
||||
print("Enter a search term and copy the namespace to clipboard\n")
|
||||
print("Paste this later to the install menu.\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", "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")
|
||||
}
|
||||
}
|
||||
|
||||
func installPak() {
|
||||
var programName, _ = input("Install: ")
|
||||
print("\n| Install Menu |\n\n")
|
||||
print("To Use: Copy paste a flatpak namespace from search results\n\n")
|
||||
print("EXAMPLE: 'com.play0ad.zeroad' - installs the Game '0ad'\n\n")
|
||||
print("Type: 'menu' for main menu\n")
|
||||
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")
|
||||
var programName, _ = input(">> ")
|
||||
|
||||
if programName == "menu" {
|
||||
return
|
||||
} else if programName == "q" {
|
||||
os.Exit(0)
|
||||
} else {
|
||||
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("\n", "Results for ", programName, ": \n\n", string(out), "\n")
|
||||
}
|
||||
|
||||
func removePak() {
|
||||
var programName, _ = input("Uninstall: ")
|
||||
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")
|
||||
}
|
||||
fmt.Print("\n", "Results for ", programName, ": \n\n", string(out), "\n\n")
|
||||
}
|
||||
|
||||
func listPak() {
|
||||
print("\n| List of installed Flatpaks |\n\n")
|
||||
cmd := exec.Command("flatpak", "list")
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
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
|
||||
@ -73,7 +112,8 @@ func optionsMenu() {
|
||||
}
|
||||
}
|
||||
*/
|
||||
func updatePak() {
|
||||
func syncRepo() {
|
||||
print("Syncing repo data...\n")
|
||||
cmd := exec.Command("flatpak", "update", "--appstream")
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
@ -83,10 +123,20 @@ func updatePak() {
|
||||
}
|
||||
|
||||
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")
|
||||
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 {
|
||||
log.Fatalf("cmd.Run() failed with %s\n", err)
|
||||
}
|
||||
@ -116,7 +166,7 @@ func mainMenu() {
|
||||
} else if choice == "5" {
|
||||
updatePak()
|
||||
} else if choice == "q" {
|
||||
os.Exit(1)
|
||||
os.Exit(0)
|
||||
} else {
|
||||
print("Unknown option")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user