From e4ae41e3a29fc3e4714e1c3f8c9f071768d17b68 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 10 Jan 2021 22:28:38 -0500 Subject: fixed all commands being legacy split running command into pre and post organizer --- src/commandline.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'src/commandline.cpp') diff --git a/src/commandline.cpp b/src/commandline.cpp index 8c722990..c31b726f 100644 --- a/src/commandline.cpp +++ b/src/commandline.cpp @@ -49,6 +49,7 @@ std::string table( CommandLine::CommandLine() + : m_command(nullptr) { createOptions(); m_commands.push_back(std::make_unique()); @@ -57,7 +58,7 @@ CommandLine::CommandLine() m_commands.push_back(std::make_unique()); } -std::optional CommandLine::run(const std::wstring& line) +std::optional CommandLine::process(const std::wstring& line) { try { @@ -125,8 +126,10 @@ std::optional CommandLine::run(const std::wstring& line) } } - // run the command - return c->run(line, m_vm, opts); + c->process(line, m_vm, opts); + m_command = c.get(); + + return m_command->runPreOrganizer(); } catch(po::error& e) { @@ -201,7 +204,7 @@ std::optional CommandLine::run(const std::wstring& line) } } -std::optional CommandLine::setupCore(OrganizerCore& organizer) const +std::optional CommandLine::run(OrganizerCore& organizer) const { if (m_shortcut.isValid()) { if (m_shortcut.hasExecutable()) { @@ -247,6 +250,8 @@ std::optional CommandLine::setupCore(OrganizerCore& organizer) const QObject::tr("failed to start application: %1").arg(e.what())); return 1; } + } else if (m_command) { + return m_command->runPostOrganizer(); } return {}; @@ -437,7 +442,7 @@ po::positional_options_description Command::positional() const bool Command::legacy() const { - return true; + return false; } std::string Command::getUsageLine() const @@ -463,8 +468,7 @@ po::positional_options_description Command::getPositional() const return {}; } - -std::optional Command::run( +void Command::process( const std::wstring& originalLine, po::variables_map vm, std::vector untouched) @@ -472,8 +476,16 @@ std::optional Command::run( m_original = originalLine; m_vm = vm; m_untouched = untouched; +} + +std::optional Command::runPreOrganizer() +{ + return {}; +} - return doRun(); +std::optional Command::runPostOrganizer() +{ + return {}; } const std::wstring& Command::originalCmd() const @@ -507,7 +519,7 @@ Command::Meta CrashDumpCommand::meta() const return {"crashdump", "writes a crashdump for a running process of MO"}; } -std::optional CrashDumpCommand::doRun() +std::optional CrashDumpCommand::runPreOrganizer() { env::Console console; @@ -537,7 +549,7 @@ bool LaunchCommand::legacy() const return true; } -std::optional LaunchCommand::doRun() +std::optional LaunchCommand::runPreOrganizer() { // needs at least the working directory and process name if (untouched().size() < 2) { @@ -643,7 +655,7 @@ Command::Meta ExeCommand::meta() const return {"exe", "launches a configured executable"}; } -std::optional ExeCommand::doRun() +std::optional ExeCommand::runPostOrganizer() { const auto exe = vm()["exe-name"].as(); const auto args = vm()["arguments"].as(); @@ -665,7 +677,7 @@ Command::Meta RunCommand::meta() const return {"run", "launches an arbitrary program"}; } -std::optional RunCommand::doRun() +std::optional RunCommand::runPostOrganizer() { std::cout << "not implemented\n"; return {}; -- cgit v1.3.1