]> git.ipfire.org Git - collecty.git/commitdiff
client: Accept a --format argument
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Oct 2025 18:21:42 +0000 (18:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Oct 2025 18:21:42 +0000 (18:21 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/client/main.c

index 1c3ad942a561b59308f43017b874a14a412b5d99..7ecf036a915be5eac9a1563bb7f11023c6fb39d8 100644 (file)
@@ -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,
        };