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