]> git.ipfire.org Git - people/ms/pakfire.git/blame - src/cli/lib/upload_list.c
cli: Check for root privileges when needed
[people/ms/pakfire.git] / src / cli / lib / upload_list.c
CommitLineData
125a95c9
MT
1/*#############################################################################
2# #
3# Pakfire - The IPFire package management system #
4# Copyright (C) 2023 Pakfire development team #
5# #
6# This program is free software: you can redistribute it and/or modify #
7# it under the terms of the GNU General Public License as published by #
8# the Free Software Foundation, either version 3 of the License, or #
9# (at your option) any later version. #
10# #
11# This program is distributed in the hope that it will be useful, #
12# but WITHOUT ANY WARRANTY; without even the implied warranty of #
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14# GNU General Public License for more details. #
15# #
16# You should have received a copy of the GNU General Public License #
17# along with this program. If not, see <http://www.gnu.org/licenses/>. #
18# #
19#############################################################################*/
20
57a8b2d4
MT
21#include <json.h>
22
aa46298c 23#include <pakfire/buildservice.h>
125a95c9
MT
24
25#include "command.h"
57a8b2d4 26#include "dump.h"
4e38be65 27#include "pakfire.h"
125a95c9
MT
28#include "upload_list.h"
29
30static const char* doc = "Lists all uploads";
31
32int cli_upload_list(void* data, int argc, char* argv[]) {
aa46298c 33 struct pakfire_buildservice* service = NULL;
57a8b2d4 34 struct json_object* uploads = NULL;
125a95c9
MT
35 int r;
36
4e38be65 37 struct cli_config* cli_config = data;
aa46298c 38
125a95c9 39 // Parse the command line
9b8d2c6e 40 r = cli_parse(NULL, NULL, NULL, doc, NULL, 0, argc, argv, NULL);
125a95c9
MT
41 if (r)
42 goto ERROR;
43
aa46298c 44 // Connect to the build service
4e38be65 45 r = pakfire_buildservice_create(&service, cli_config->ctx);
aa46298c
MT
46 if (r)
47 goto ERROR;
48
57a8b2d4
MT
49 // List uploads
50 r = pakfire_buildservice_list_uploads(service, &uploads);
51 if (r)
52 goto ERROR;
53
54 // Dump everything
55 r = cli_dump_json(uploads);
56 if (r)
57 goto ERROR;
125a95c9
MT
58
59ERROR:
aa46298c
MT
60 if (service)
61 pakfire_buildservice_unref(service);
57a8b2d4
MT
62 if (uploads)
63 json_object_put(uploads);
aa46298c 64
125a95c9
MT
65 return r;
66}