Wyst package manager

This commit is contained in:
RudideC
2024-05-18 19:21:40 +02:00
parent c5c4a53ded
commit 7c50a30987
7 changed files with 237 additions and 19 deletions
+36
View File
@@ -0,0 +1,36 @@
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func showPackageInfo(packageName string) {
url := fmt.Sprintf("https://raw.githubusercontent.com/wyst-lang/index/master/%s/index.json", packageName)
resp, err := http.Get(url)
if err != nil {
fmt.Printf("Error fetching package info: %v\n", err)
return
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
fmt.Printf("Error: %s\n", resp.Status)
return
}
var pkgIndex PackageIndex
if err := json.NewDecoder(resp.Body).Decode(&pkgIndex); err != nil {
fmt.Printf("Error decoding package info: %v\n", err)
return
}
fmt.Printf("Package: %s\n", packageName)
for version, info := range pkgIndex.Versions {
fmt.Printf("Version: %s\n", version)
fmt.Printf(" Author: %s\n", info.Author)
fmt.Printf(" Description: %s\n", info.Description)
fmt.Println()
}
}