Merge branch 'master' of github.com:wyst-lang/wyst-package-manager

This commit is contained in:
2024-05-22 21:27:42 +02:00
2 changed files with 19 additions and 2 deletions
+4 -2
View File
@@ -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)
+15
View File
@@ -3,6 +3,8 @@ package main
import (
"fmt"
"os"
"os/exec"
"runtime"
"strings"
"golang.org/x/term"
@@ -76,3 +78,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()
}
}