]> git.ipfire.org Git - pakfire.git/commitdiff
cli: client: Create scaffolding for the client implemented in C
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Oct 2023 09:20:02 +0000 (09:20 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Oct 2023 09:20:02 +0000 (09:20 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/cli/pakfire-client.c [new file with mode: 0644]

index 1eb72c8f44de1f4c592a4e32175b1ffa8e751102..34d86759aadc9d298c00bb5ab777ab9ee0451626 100644 (file)
@@ -427,6 +427,28 @@ pakfire_builder_LDADD = \
 
 # ------------------------------------------------------------------------------
 
+bin_PROGRAMS += \
+       pakfire-client
+
+pakfire_client_SOURCES = \
+       src/cli/pakfire-client.c
+
+pakfire_client_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       -I$(top_srcdir)/src/libpakfire/include
+
+pakfire_client_CFLAGS = \
+       $(AM_CFLAGS)
+
+pakfire_client_LDFLAGS = \
+       $(AM_LDFLAGS)
+
+pakfire_client_LDADD = \
+       libpakfire.la \
+       libcli.la
+
+# ------------------------------------------------------------------------------
+
 noinst_LTLIBRARIES += \
        libcli.la
 
diff --git a/src/cli/pakfire-client.c b/src/cli/pakfire-client.c
new file mode 100644 (file)
index 0000000..594392d
--- /dev/null
@@ -0,0 +1,59 @@
+/*#############################################################################
+#                                                                             #
+# Pakfire - The IPFire package management system                              #
+# Copyright (C) 2023 Pakfire development team                                 #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include <argp.h>
+
+#include <pakfire/ctx.h>
+
+#include "lib/command.h"
+#include "lib/progressbar.h"
+
+const char* argp_program_version = PACKAGE_VERSION;
+
+static const struct command commands[] = {
+       // No commands, yet
+       { NULL },
+};
+
+static const char* args_doc = NULL;
+
+static const char* doc = "The Pakfire Build Service Client Tool";
+
+int main(int argc, char* argv[]) {
+       struct pakfire_ctx* ctx = NULL;
+       int r;
+
+       // Setup the context
+       r = pakfire_ctx_create(&ctx, NULL);
+       if (r)
+               goto ERROR;
+
+       // Setup progress callback
+       pakfire_ctx_set_progress_callback(ctx, cli_setup_progressbar, NULL);
+
+       // Parse the command line and run any commands
+       r = cli_parse(NULL, commands, args_doc, doc, NULL, argc, argv, &ctx);
+
+ERROR:
+       if (ctx)
+               pakfire_ctx_unref(ctx);
+
+       return r;
+}