flatface.go: Added colors to text ouput
This commit is contained in:
parent
279e2d390d
commit
43108b31f6
73
flatface.go
73
flatface.go
@ -7,8 +7,18 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func clearScreen() {
|
||||||
|
cmd := exec.Command("clear")
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
searchRepo()
|
||||||
|
}
|
||||||
|
fmt.Print(string(out))
|
||||||
|
}
|
||||||
func input(s string) (string, error) {
|
func input(s string) (string, error) {
|
||||||
stdinBuf := bufio.NewReader(os.Stdin)
|
stdinBuf := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
@ -22,11 +32,13 @@ func input(s string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func searchRepo() {
|
func searchRepo() {
|
||||||
print("\n| Search Repositories |\n\n")
|
color.Set(color.FgHiCyan)
|
||||||
|
print("\n| Search Repositories |\n")
|
||||||
print("Enter a search term and copy the namespace to clipboard\n")
|
print("Enter a search term and copy the namespace to clipboard\n")
|
||||||
print("Paste this later to the install menu.\n\n")
|
print("Paste this later to the install menu.\n\n")
|
||||||
print("Type: 'm' for main menu\n")
|
print("Type: 'm' for main menu\n")
|
||||||
print("Type: 'q' to quit the application\n\n")
|
print("Type: 'q' to quit the application\n\n")
|
||||||
|
color.Unset()
|
||||||
|
|
||||||
var programName, _ = input(">> ")
|
var programName, _ = input(">> ")
|
||||||
|
|
||||||
@ -42,18 +54,24 @@ func searchRepo() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
searchRepo()
|
searchRepo()
|
||||||
}
|
}
|
||||||
fmt.Print("\n", "Results for ", trimInput, ": \n\n", string(out), "\n")
|
color.Set(color.FgHiGreen)
|
||||||
|
print("\n==============================================================\n")
|
||||||
|
fmt.Print("Results for ", trimInput, ": \n\n", string(out), "\n")
|
||||||
|
print("\n\n==============================================================\n")
|
||||||
|
color.Unset()
|
||||||
searchRepo()
|
searchRepo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func installPak() {
|
func installPak() {
|
||||||
|
color.Set(color.FgHiCyan)
|
||||||
print("\n| Install Menu |\n\n")
|
print("\n| Install Menu |\n\n")
|
||||||
print("To Use: Copy paste a flatpak namespace from search results\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("EXAMPLE: 'com.play0ad.zeroad' - installs the Game '0ad'\n\n")
|
||||||
print("Type: 'm' for main menu\n")
|
print("Type: 'm' for main menu\n")
|
||||||
print("Type: 'q' to quit the application\n\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")
|
print("NOTE: install can take several seconds and appear to hang. Please be patient...\n\n")
|
||||||
|
color.Unset()
|
||||||
var programName, _ = input(">> ")
|
var programName, _ = input(">> ")
|
||||||
|
|
||||||
trimInput := strings.TrimSpace(programName)
|
trimInput := strings.TrimSpace(programName)
|
||||||
@ -71,27 +89,42 @@ func installPak() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
installPak()
|
installPak()
|
||||||
}
|
}
|
||||||
|
color.Set(color.FgHiGreen)
|
||||||
|
print("\n==========================================================================\n\n")
|
||||||
fmt.Print(string(out), "\n")
|
fmt.Print(string(out), "\n")
|
||||||
|
print("\n============================================================================\n\n")
|
||||||
|
color.Unset()
|
||||||
installPak()
|
installPak()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func listPak() {
|
func listPak() {
|
||||||
print("\n| List of installed Flatpaks |\n\n")
|
color.Set(color.FgHiGreen)
|
||||||
|
print("\n| List of installed Flatpaks |\n")
|
||||||
|
color.Unset()
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
color.Set(color.FgHiYellow)
|
||||||
|
print("\n============================================================================\n\n")
|
||||||
fmt.Print(string(out), "\n\n")
|
fmt.Print(string(out), "\n\n")
|
||||||
|
print("\n============================================================================\n\n")
|
||||||
|
color.Unset()
|
||||||
}
|
}
|
||||||
|
|
||||||
func removePak() {
|
func removePak() {
|
||||||
print("\n| Remove Flatpaks |\n\n")
|
color.Set(color.FgHiCyan)
|
||||||
|
print("\n| Remove Flatpaks |\n")
|
||||||
|
color.Unset()
|
||||||
listPak()
|
listPak()
|
||||||
|
color.Set(color.FgHiCyan)
|
||||||
print("\n\nCopy and paste a namespace above and press enter to remove from system\n\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: 'm' for main menu\n")
|
||||||
print("Type: 'q' to quit the application\n\n")
|
print("Type: 'q' to quit the application\n\n")
|
||||||
|
color.Unset()
|
||||||
var programName, _ = input(">> ")
|
var programName, _ = input(">> ")
|
||||||
|
|
||||||
trimInput := strings.TrimSpace(programName)
|
trimInput := strings.TrimSpace(programName)
|
||||||
@ -106,7 +139,11 @@ func removePak() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
removePak()
|
removePak()
|
||||||
}
|
}
|
||||||
|
color.Set(color.FgHiRed)
|
||||||
|
print("\n==========================================================================\n\n")
|
||||||
fmt.Print(string(out), "\n\n")
|
fmt.Print(string(out), "\n\n")
|
||||||
|
print("\n==========================================================================\n\n")
|
||||||
|
color.Unset()
|
||||||
removePak()
|
removePak()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,16 +163,23 @@ func optionsMenu() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
func syncRepo() {
|
func syncRepo() {
|
||||||
|
color.Set(color.FgHiMagenta)
|
||||||
print("Syncing repo data...\n")
|
print("Syncing repo data...\n")
|
||||||
|
color.Unset()
|
||||||
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 {
|
||||||
log.Fatalf("cmd.Run() failed with %s\n", err)
|
log.Fatalf("cmd.Run() failed with %s\n", err)
|
||||||
}
|
}
|
||||||
|
color.Set(color.FgHiGreen)
|
||||||
fmt.Print(string(out))
|
fmt.Print(string(out))
|
||||||
|
color.Unset()
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkRepo() {
|
func checkRepo() {
|
||||||
|
color.Set(color.FgHiYellow)
|
||||||
print("\nAdding flathub repo if needed...\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()
|
||||||
@ -147,23 +191,30 @@ func checkRepo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updatePak() {
|
func updatePak() {
|
||||||
|
color.Set(color.FgHiYellow)
|
||||||
print("Checking for app upgrades..\n")
|
print("Checking for app upgrades..\n")
|
||||||
|
color.Unset()
|
||||||
cmd := exec.Command("flatpak", "update")
|
cmd := exec.Command("flatpak", "update")
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
color.Set(color.FgHiGreen)
|
||||||
fmt.Print(string(out))
|
fmt.Print(string(out))
|
||||||
|
color.Unset()
|
||||||
}
|
}
|
||||||
func mainMenu() {
|
func mainMenu() {
|
||||||
print("\n\n| FlatFace v0.0.1a-3 |\n\n")
|
color.Set(color.FgHiCyan)
|
||||||
|
print("\n\n| FlatFace v0.0.1a-4 |\n\n")
|
||||||
var choice string
|
var choice string
|
||||||
print("[S]earch remote for flatpaks\n")
|
|
||||||
print("[I]nstall flatpaks from remote\n")
|
print("[s] Search remote for flatpaks\n")
|
||||||
print("[R]emove local flatpaks\n")
|
print("[l] Install flatpaks from remote\n")
|
||||||
print("[L]ist install flatpaks\n")
|
print("[r] Remove local flatpaks\n")
|
||||||
print("[U]pdate\n")
|
print("[l] List install flatpaks\n")
|
||||||
print("[Q]uit\n\n")
|
print("[u] Update\n")
|
||||||
|
print("[q] Quit\n\n")
|
||||||
|
color.Unset()
|
||||||
|
|
||||||
choice, _ = input(">> ")
|
choice, _ = input(">> ")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user