]>
git.ipfire.org Git - pakfire.git/blob - src/cli/pakfire-client.c
1 /*#############################################################################
3 # Pakfire - The IPFire package management system #
4 # Copyright (C) 2023 Pakfire development team #
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. #
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. #
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/>. #
19 #############################################################################*/
24 #include <pakfire/ctx.h>
26 #include "lib/client-build.h"
27 #include "lib/command.h"
28 #include "lib/config.h"
29 #include "lib/pakfire.h"
30 #include "lib/progressbar.h"
32 #include "lib/upload.h"
34 const char* argp_program_version
= PACKAGE_VERSION
;
36 static const struct command commands
[] = {
37 { "build", cli_client_build
, 1, -1, 0 },
38 { "repo", cli_repo_client
, -1, -1, 0 },
39 { "upload", cli_upload
, -1, -1, 0 },
43 static const char* args_doc
=
47 static const char* doc
= "The Pakfire Build Service Client Tool";
54 static struct argp_option options
[] = {
55 { "debug", OPT_DEBUG
, NULL
, 0, "Run in debug mode", 0 },
56 { "distro", OPT_DISTRO
, "DISTRO", 0, "Choose the distribution", 0 },
60 static error_t
parse(int key
, char* arg
, struct argp_state
* state
, void* data
) {
61 struct cli_config
* config
= data
;
65 pakfire_ctx_set_log_level(config
->ctx
, LOG_DEBUG
);
73 return ARGP_ERR_UNKNOWN
;
79 int main(int argc
, char* argv
[]) {
80 struct pakfire_ctx
* ctx
= NULL
;
84 r
= pakfire_ctx_create(&ctx
, NULL
);
88 // Setup progress callback
89 pakfire_ctx_set_progress_callback(ctx
, cli_setup_progressbar
, NULL
);
91 struct cli_config config
= {
93 .distro
= cli_get_default_distro(ctx
),
96 // Parse the command line and run any commands
97 r
= cli_parse(options
, commands
, args_doc
, doc
,
98 parse
, 0, argc
, argv
, &config
);
102 pakfire_ctx_unref(ctx
);