feat: Update 2 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 1m15s
Build-Test-Publish / build (linux/arm64) (push) Successful in 2m6s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Successful in 7s
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Successful in 7s
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 1m15s
Build-Test-Publish / build (linux/arm64) (push) Successful in 2m6s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Successful in 7s
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Successful in 7s
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
using json = nlohmann::json;
|
||||
@ -207,7 +208,7 @@ bool GetbinClient::deleteObject(const std::string& hash, const std::string& toke
|
||||
|
||||
bool GetbinClient::listPackages(std::vector<std::string>& outPackages) {
|
||||
try {
|
||||
std::string url = "https://" + SERVER_HOST + "/packages";
|
||||
std::string url = "https://" + SERVER_HOST + "/dir";
|
||||
|
||||
auto response = cpr::Get(cpr::Url{url},
|
||||
cpr::Header{{"User-Agent", getUserAgent()}},
|
||||
@ -217,21 +218,32 @@ bool GetbinClient::listPackages(std::vector<std::string>& outPackages) {
|
||||
if (response.status_code == 200) {
|
||||
try {
|
||||
auto resp_json = json::parse(response.text);
|
||||
if (resp_json.is_array()) {
|
||||
if (resp_json.contains("entries") && resp_json["entries"].is_array()) {
|
||||
outPackages.clear();
|
||||
for (const auto& item : resp_json) {
|
||||
if (item.is_string()) {
|
||||
outPackages.push_back(item.get<std::string>());
|
||||
std::set<std::string> uniqueTools;
|
||||
|
||||
for (const auto& entry : resp_json["entries"]) {
|
||||
if (entry.contains("labeltags") && entry["labeltags"].is_array()) {
|
||||
for (const auto& labeltag : entry["labeltags"]) {
|
||||
if (labeltag.is_string()) {
|
||||
std::string tag = labeltag.get<std::string>();
|
||||
// Extract tool name from "tool:arch" format
|
||||
size_t colonPos = tag.find(":");
|
||||
if (colonPos != std::string::npos) {
|
||||
std::string toolName = tag.substr(0, colonPos);
|
||||
if (!toolName.empty()) {
|
||||
uniqueTools.insert(toolName);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (resp_json.contains("packages") && resp_json["packages"].is_array()) {
|
||||
outPackages.clear();
|
||||
for (const auto& item : resp_json["packages"]) {
|
||||
if (item.is_string()) {
|
||||
outPackages.push_back(item.get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert set to vector
|
||||
for (const auto& tool : uniqueTools) {
|
||||
outPackages.push_back(tool);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (const json::exception&) {
|
||||
|
@ -824,7 +824,7 @@ int list_packages(int argc, char* argv[]) {
|
||||
for (const auto& packageName : availablePackages) {
|
||||
std::string status = "Available";
|
||||
std::string localVersion = "-";
|
||||
std::string remoteStatus = "✓";
|
||||
std::string remoteStatus = "-";
|
||||
|
||||
auto it = installedPackages.find(packageName);
|
||||
if (it != installedPackages.end()) {
|
||||
|
Reference in New Issue
Block a user