From f7057c769c00bd7781d6b5173ad0601593ab6c42 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 2 Oct 2025 18:21:42 +0000 Subject: [PATCH] client: Accept a --format argument Signed-off-by: Michael Tremer --- src/client/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/client/main.c b/src/client/main.c index 1c3ad94..7ecf036 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -30,6 +30,11 @@ const char* argp_program_version = PACKAGE_VERSION; static const char* doc = "The collecty client that can draw graphs"; typedef struct collecty_client_ctx { + enum { + // Enables debugging output + DEBUG = (1 << 0), + } flags; + // DBus sd_bus* bus; @@ -43,10 +48,23 @@ typedef struct collecty_client_ctx { FILE* f; } collecty_client_ctx; +enum { + OPT_FORMAT = 1, +}; + +static struct argp_option options[] = { + { "format", OPT_FORMAT, "FORMAT", 0, "Output Format", 0 }, + { NULL }, +}; + static error_t parse(int key, char* arg, struct argp_state* state) { collecty_client_ctx* ctx = state->input; switch (key) { + case OPT_FORMAT: + ctx->format = arg; + break; + // Called for each argument case ARGP_KEY_ARG: // Take the graph name as first argument @@ -120,6 +138,7 @@ ERROR: int main(int argc, char* argv[]) { struct argp parser = { + .options = options, .parser = parse, .doc = doc, }; -- 2.47.3