From 30582cfb0520bb1841301dbe9882ad69f0e784b5 Mon Sep 17 00:00:00 2001 From: joevt Date: Fri, 16 Aug 2024 02:37:58 -0700 Subject: [PATCH] main: Make realtime and debugger flags exclusive. Put them in a separate option group named "execution mode" and specify that only one of them can be selected. CLI11 will handle the error message if the user attempts to set both options. --- main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index b132396..59a169e 100644 --- a/main.cpp +++ b/main.cpp @@ -104,9 +104,11 @@ int main(int argc, char** argv) { string bootrom_path("bootrom.bin"); string working_directory_path("."); - app.add_flag("-r,--realtime", realtime_enabled, + auto execution_mode_group = app.add_option_group("execution mode") + ->require_option(-1); + execution_mode_group->add_flag("-r,--realtime", realtime_enabled, "Run the emulator in real-time"); - app.add_flag("-d,--debugger", debugger_enabled, + execution_mode_group->add_flag("-d,--debugger", debugger_enabled, "Enter the built-in debugger"); app.add_option("-w,--workingdir", working_directory_path, "Specifies working directory") ->check(WorkingDirectory); @@ -158,8 +160,6 @@ int main(int argc, char** argv) { } if (debugger_enabled) { - if (realtime_enabled) - cout << "Both realtime and debugger enabled! Using debugger" << endl; execution_mode = debugger; }