diff --git a/src/commands.cpp b/src/commands.cpp index 63581a5..d218811 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -11,8 +11,19 @@ namespace mob constexpr bool do_timings = false; -// in main.cpp -void set_sigint_handler(); + +BOOL WINAPI signal_handler(DWORD) noexcept +{ + gcx().debug(context::generic, "caught sigint"); + task::interrupt_all(); + return TRUE; +} + +void set_sigint_handler() +{ + ::SetConsoleCtrlHandler(mob::signal_handler, TRUE); +} + std::string version() diff --git a/src/main.cpp b/src/main.cpp index 898e62f..3f736cb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,18 @@ namespace mob void add_tasks() { + // add new tasks here + + // top level tasks are run sequentially, tasks added to a parallel_tasks will + // run in parallel; which tasks are run in parallel is somewhat arbitrary when + // there's no dependency, the goal is just to saturate the cpu + + // mob doesn't have a concept of task dependencies, just task ordering, so + // if a task depends on another, it has to be earlier in the order + + + // third-party tasks + add_task(false) .add_task() .add_task() @@ -43,6 +55,8 @@ void add_tasks() .add_task(); + // super tasks + using mo = modorganizer; // most of the alternate names below are from the transifex slugs, which @@ -113,11 +127,14 @@ void add_tasks() add_task(); } +// figures out which command to run and returns it, if any +// std::shared_ptr handle_command_line(const std::vector& args) { auto help = std::make_shared(); auto build = std::make_shared(); + // available commands std::vector> commands = { help, @@ -132,21 +149,26 @@ std::shared_ptr handle_command_line(const std::vector& arg std::make_unique() }; + // commands are shown in the help help->set_commands(commands); - std::vector command_groups; - for (auto& c : commands) - command_groups.push_back(c->group()); + // root group with all the command groups clipp::group all_groups; - all_groups.scoped(false); - all_groups.exclusive(true); - for (auto& c : command_groups) - all_groups.push_back(c); + // not sure, actually + all_groups.scoped(false); + + // child groups are exclusive, that is, only one command can be given + all_groups.exclusive(true); + + for (auto& c : commands) + all_groups.push_back(c->group()); + + + // vs reports a no-op on the left side of the comman, which is incorrect #pragma warning(suppress: 4548) auto cli = (all_groups, command::common_options_group()); - auto pr = clipp::parse(args, cli); if (!pr) @@ -176,20 +198,6 @@ std::shared_ptr handle_command_line(const std::vector& arg return {}; } - -BOOL WINAPI signal_handler(DWORD) noexcept -{ - gcx().debug(context::generic, "caught sigint"); - task::interrupt_all(); - return TRUE; -} - -void set_sigint_handler() -{ - ::SetConsoleCtrlHandler(mob::signal_handler, TRUE); -} - - int run(const std::vector& args) { font_restorer fr; @@ -217,7 +225,10 @@ int run(const std::vector& args) int wmain(int argc, wchar_t** argv) { + // makes streams unicode mob::set_std_streams(); + + // outputs stacktrace on crash mob::set_thread_exception_handlers(); std::vector args;