From 37db3e216e508b19228479f39b935caa61815d06 Mon Sep 17 00:00:00 2001 From: Amin Ben Romdhane <amin.benromdhane@iopsys.eu> Date: Tue, 6 May 2025 21:09:18 +0200 Subject: [PATCH] Add support for displaying the schema data model with '-d' option --- src/main.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 51e54a2..0d22ba1 100644 --- a/src/main.c +++ b/src/main.c @@ -253,6 +253,7 @@ static void usage(const char *prog) fprintf(stderr, "\n"); fprintf(stderr, "options:\n"); fprintf(stderr, " -l <0-7> Set the loglevel\n"); + fprintf(stderr, " -d <schema dm> Display the schema data model supported by micro-service\n"); fprintf(stderr, " -h Displays this help\n"); fprintf(stderr, "\n"); } @@ -260,9 +261,9 @@ static void usage(const char *prog) int main(int argc, char **argv) { int log_level = 7; - int c = 0; + int c = 0, dm_type = 0; - while ((c = getopt(argc, argv, "hl:")) != -1) { + while ((c = getopt(argc, argv, "hdl:")) != -1) { switch (c) { case 'l': log_level = (int)strtod(optarg, NULL); @@ -270,6 +271,9 @@ int main(int argc, char **argv) log_level = 7; } break; + case 'd': + dm_type++; + break; case 'h': usage(argv[0]); exit(0); @@ -278,18 +282,24 @@ int main(int argc, char **argv) exit(0); } } - load_system_users(); - load_system_groups(); memset(&bbfdm_ctx, 0, sizeof(struct bbfdm_context)); - create_groups(); - create_users(); - bbfdm_ubus_set_service_name(&bbfdm_ctx, "usermngr"); bbfdm_ubus_set_log_level(log_level); bbfdm_ubus_load_data_model(tDynamicObj); + if (dm_type > 0) { + int res = bbfdm_print_data_model_schema(&bbfdm_ctx, dm_type); + exit(res); + } + + load_system_users(); + load_system_groups(); + + create_groups(); + create_users(); + if (bbfdm_ubus_regiter_init(&bbfdm_ctx)) goto out; -- GitLab