From b0d97f901f44b50cc98c8fd1896740d7dcee8cd1 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Tue, 21 Apr 2020 09:20:09 +0200 Subject: [PATCH] Adding printing of subcommands help --- inc/lektor/cmd.h | 2 +- src/cmd.c | 10 ++++++++++ src/main/lktadm.c | 10 +++++----- src/module/module_sdl2.c | 6 +----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/inc/lektor/cmd.h b/inc/lektor/cmd.h index 905e132c..98817754 100644 --- a/inc/lektor/cmd.h +++ b/inc/lektor/cmd.h @@ -18,7 +18,7 @@ struct lkt_cmd_opt { const char *name; lkt_cmd_callback call; const char *help; - int sub; + struct lkt_cmd_opt *sub; }; /* Parse the command line with the list of options. No parameter may be NULL. diff --git a/src/cmd.c b/src/cmd.c index 11a33c0c..37dc689c 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -84,4 +84,14 @@ lkt_cmd_help(struct lkt_cmd_opt *opts, const char *name) printf("\t%*s %s\n", max_len, it->name, it->help); it = opts + (++offset); } + + /* Prints the sub commands help */ + it = opts; + offset = 0; + write(1, "\n", sizeof(char)); + while (it && it->name) { + if (it->sub) + lkt_cmd_help(it->sub, it->name); + it = opts + (++offset); + } } diff --git a/src/main/lktadm.c b/src/main/lktadm.c index 90a7c7a5..2834dc2e 100644 --- a/src/main/lktadm.c +++ b/src/main/lktadm.c @@ -292,11 +292,11 @@ init__(struct lkt_cmd_args *args) } static struct lkt_cmd_opt options[] = { - { .name = "init", .call = init__, .help = "The init sub-command", .sub = 1 }, - { .name = "get", .call = get__, .help = "Get the mdt of a kara by its id" }, - { .name = "download", .call = download__, .help = "Download a kara by its id" }, - { .name = "cat", .call = cat__, .help = "Prints the mdt of a kara on the fs" }, - { .name = "conf", .call = conf__, .help = "Prints out the default config" }, + { .name = "init", .call = init__, .help = "The init sub-command", .sub = options_init }, + { .name = "get", .call = get__, .help = "Get the mdt of a kara by its id" }, + { .name = "download", .call = download__, .help = "Download a kara by its id" }, + { .name = "cat", .call = cat__, .help = "Prints the mdt of a kara on the fs" }, + { .name = "conf", .call = conf__, .help = "Prints out the default config" }, LKT_OPT_NULL, }; diff --git a/src/module/module_sdl2.c b/src/module/module_sdl2.c index ab619b24..94c2e957 100644 --- a/src/module/module_sdl2.c +++ b/src/module/module_sdl2.c @@ -156,17 +156,14 @@ loop: break; case SDL_WINDOWEVENT: - if (event.window.event == SDL_WINDOWEVENT_EXPOSED) { - fprintf(stderr, " . sdl_thread__: Window exposed\n"); + if (event.window.event == SDL_WINDOWEVENT_EXPOSED) redraw = 1; - } break; case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_SPACE) { const char *cmd_pause[] = { "cycle", "pause", NULL }; mpv_command_async((mpv_handle *) sdl2->mpv, 0, cmd_pause); - fprintf(stderr, " . sdl_thread__: Toggle pause\n"); } break; @@ -178,7 +175,6 @@ loop: SDL_SetWindowFullscreen((SDL_Window *) sdl2->window, SDL_WINDOW_FULLSCREEN); /* May use SDL_WINDOW_FULLSCREEN_DESKTOP, need to check. */ sdl2->is_fullscreen = 1 - sdl2->is_fullscreen; - fprintf(stderr, " . sdl_thread__: Toggle fullscreen\n"); } break; -- GitLab