Improve this
This commit is contained in:
1 file changed
+2
-8
@@ -7,18 +7,14 @@ void version_command(int argc, char *argv[]) {
|
|||||||
printf("Current TBCLI Version: %s\n", PROJECT_VERSION);
|
printf("Current TBCLI Version: %s\n", PROJECT_VERSION);
|
||||||
|
|
||||||
char *body = http_get("https://git.lncvrt.xyz/api/v1/repos/TBCLI/cli/tags");
|
char *body = http_get("https://git.lncvrt.xyz/api/v1/repos/TBCLI/cli/tags");
|
||||||
if (!body) {
|
if (!body)
|
||||||
fprintf(stderr, "Failed to fetch tags\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *json = cJSON_Parse(body);
|
cJSON *json = cJSON_Parse(body);
|
||||||
free(body);
|
free(body);
|
||||||
|
|
||||||
if (!json) {
|
if (!json)
|
||||||
fprintf(stderr, "Failed to parse JSON\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
cJSON *latest = cJSON_GetArrayItem(json, cJSON_GetArraySize(json) - 1);
|
cJSON *latest = cJSON_GetArrayItem(json, cJSON_GetArraySize(json) - 1);
|
||||||
if (latest) {
|
if (latest) {
|
||||||
@@ -26,8 +22,6 @@ void version_command(int argc, char *argv[]) {
|
|||||||
if (cJSON_IsString(name)) {
|
if (cJSON_IsString(name)) {
|
||||||
printf("Latest TBCLI Version: %s\n", name->valuestring);
|
printf("Latest TBCLI Version: %s\n", name->valuestring);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
printf("No tags found.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON_Delete(json);
|
cJSON_Delete(json);
|
||||||
|
|||||||
Reference in new issue
Block a user