From 95ac849fba3c0d57f7ad02ca2d7c82476f9450b2 Mon Sep 17 00:00:00 2001 From: mollusk Date: Wed, 3 Jan 2018 00:54:49 -0700 Subject: [PATCH] flatface.go: return to current menu after action --- flatface.go | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/flatface.go b/flatface.go index a51766b..0d26080 100644 --- a/flatface.go +++ b/flatface.go @@ -9,11 +9,11 @@ import ( ) func input(s string) (string, error) { - stdin_buf := bufio.NewReader(os.Stdin) + stdinBuf := bufio.NewReader(os.Stdin) fmt.Print(s) - text, err := stdin_buf.ReadString('\n') + text, err := stdinBuf.ReadString('\n') if err != nil { panic(err) } @@ -24,12 +24,12 @@ func searchRepo() { 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: 'm' for main menu\n") print("Type: 'q' to quit the application\n\n") var programName, _ = input(">> ") - if programName == "menu" { + if programName == "m" { return } else if programName == "q" { os.Exit(0) @@ -40,6 +40,7 @@ func searchRepo() { log.Fatalf("cmd.Run() failed with %s\n", err) } fmt.Print("\n", "Results for ", programName, ": \n\n", string(out), "\n") + searchRepo() } } @@ -47,12 +48,12 @@ func installPak() { 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: 'm' 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" { + if programName == "m" { return } else if programName == "q" { os.Exit(0) @@ -63,6 +64,7 @@ func installPak() { log.Fatalf("cmd.Run() failed with %s\n", err) } fmt.Print(string(out), "\n") + installPak() } } @@ -77,14 +79,14 @@ func listPak() { } func removePak() { - print("\n| Uninstall Flatpaks |\n\n") + print("\n| Remove 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("\n\nCopy and paste a namespace above and press enter to remove from system\n\n") + print("Type: 'm' for main menu\n") print("Type: 'q' to quit the application\n\n") var programName, _ = input(">> ") - if programName == "menu" { + if programName == "m" { return } else if programName == "q" { os.Exit(0) @@ -95,6 +97,7 @@ func removePak() { log.Fatalf("cmd.Run() failed with %s\n", err) } fmt.Print(string(out), "\n\n") + removePak() } } @@ -143,27 +146,27 @@ func updatePak() { fmt.Print(string(out)) } func mainMenu() { - print("\n\n| FlatFace v0.0.1a |\n\n") + print("\n\n| FlatFace v0.0.1a-3 |\n\n") var choice string - print("1. Search remote for flatpaks\n") - print("2. Install flatpaks from remote\n") - print("3. Uninstall local flatpaks\n") - print("4. List install flatpaks\n") - print("5. Update\n") - print("q. Quit\n\n") + print("[S]earch remote for flatpaks\n") + print("[I]nstall flatpaks from remote\n") + print("[R]emove local flatpaks\n") + print("[L]ist install flatpaks\n") + print("[U]pdate\n") + print("[Q]uit\n\n") choice, _ = input(">> ") - if choice == "1" { + if choice == "s" { searchRepo() - } else if choice == "2" { + } else if choice == "i" { installPak() - } else if choice == "3" { + } else if choice == "r" { removePak() - } else if choice == "4" { + } else if choice == "l" { listPak() - } else if choice == "5" { + } else if choice == "u" { updatePak() } else if choice == "q" { os.Exit(0)