Added a clear and fixed issues
Clear is a cross platform function that, as its name implies, clears the terminal/command prompt. Fixed issue related to sending edit requests even if pms is unavailable
This commit is contained in:
+4
-2
@@ -48,13 +48,15 @@ func createPackage(packageName string) {
|
||||
jsonBody := []byte(fmt.Sprintf(`{"name": "%v", "psw": "%v", "repo": "%v", "latest": "%v"}`, packageName, psw, repo, version))
|
||||
_, err := sendRequest(http.MethodPost, URL, jsonBody)
|
||||
if err != nil {
|
||||
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
func editPackage(packageName string) {
|
||||
pkgidx, err := getPackage(packageName)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
var psw string
|
||||
var repo string = pkgidx.Repo
|
||||
@@ -67,7 +69,7 @@ func editPackage(packageName string) {
|
||||
newPsw = psw
|
||||
|
||||
for true {
|
||||
fmt.Printf("\033[2J")
|
||||
clear()
|
||||
fmt.Println("Choose what you want to modify")
|
||||
fmt.Printf(" 1 -> package name: %s\n", newPackageName)
|
||||
fmt.Printf(" 2 -> password: %s\n", newPsw)
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/term"
|
||||
@@ -72,3 +74,16 @@ func ReadPassword(buff *string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func clear() {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
cmd := exec.Command("cmd", "/c", "cls")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Run()
|
||||
default: // Unix-like systems
|
||||
cmd := exec.Command("clear")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Run()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user