From b66b37c767305269c9a8527d04d0267b9502b418 Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Fri, 1 May 2026 14:36:27 +0000 Subject: [PATCH] feat: add frontend selection flags to main.c Co-authored-by: aider (deepseek/deepseek-coder) --- main.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 76f8838..76c4bff 100644 --- a/main.c +++ b/main.c @@ -2,8 +2,11 @@ #include #include #include +#include #include "engine.h" #include "tui.h" +#include "cli.h" +#include "gui.h" static Engine engine; static volatile int keep_running = 1; @@ -18,15 +21,19 @@ void print_usage(const char *program) { printf("Options:\n"); printf(" -n JACK client name (default: jack-looper)\n"); printf(" -c MIDI control channel (default: 0)\n"); + printf(" -t Use TUI frontend (default)\n"); + printf(" -i Use CLI frontend (interactive)\n"); + printf(" -g Use GUI frontend\n"); printf(" -h Show this help\n"); } int main(int argc, char *argv[]) { const char *client_name = "jack-looper"; int control_channel = 0; + enum { FRONTEND_TUI, FRONTEND_CLI, FRONTEND_GUI } frontend = FRONTEND_TUI; int opt; - while ((opt = getopt(argc, argv, "n:c:h")) != -1) { + while ((opt = getopt(argc, argv, "n:c:tigh")) != -1) { switch (opt) { case 'n': client_name = optarg; @@ -38,6 +45,15 @@ int main(int argc, char *argv[]) { return 1; } break; + case 't': + frontend = FRONTEND_TUI; + break; + case 'i': + frontend = FRONTEND_CLI; + break; + case 'g': + frontend = FRONTEND_GUI; + break; case 'h': print_usage(argv[0]); return 0; @@ -72,13 +88,23 @@ int main(int argc, char *argv[]) { printf("Sample rate: %u Hz\n", engine.sample_rate); printf("Press Ctrl+C to stop\n\n"); - // Initialize and run TUI - tui_init(&engine); - tui_run(&engine); - tui_cleanup(); + // Run selected frontend + switch (frontend) { + case FRONTEND_TUI: + tui_init(&engine); + tui_run(&engine); + tui_cleanup(); + break; + case FRONTEND_CLI: + cli_run(&engine); + break; + case FRONTEND_GUI: + gui_main(&engine); + break; + } // Cleanup - printf("\nShutting down...\n"); // This line may not be reached if tui_run returns + printf("\nShutting down...\n"); engine_stop(&engine); engine_cleanup(&engine);