| 1 |
#include "CliExtension.hh" |
| 2 |
|
| 3 |
#include "CommandLineParser.hh" |
| 4 |
#include "HardwareConfig.hh" |
| 5 |
#include "MSXException.hh" |
| 6 |
#include "MSXMotherBoard.hh" |
| 7 |
|
| 8 |
#include <cassert> |
| 9 |
|
| 10 |
namespace openmsx { |
| 11 |
|
| 12 |
CliExtension::CliExtension(CommandLineParser& cmdLineParser_) |
| 13 |
: cmdLineParser(cmdLineParser_) |
| 14 |
{ |
| 15 |
for (const auto* ext : {"-ext", "-exta", "-extb", "-extc", "-extd"}) { |
| 16 |
cmdLineParser.registerOption(ext, *this); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
void CliExtension::parseOption(const std::string& option, std::span<std::string>& cmdLine) |
| 21 |
{ |
| 22 |
try { |
| 23 |
std::string extensionName = getArgument(option, cmdLine); |
| 24 |
MSXMotherBoard* motherboard = cmdLineParser.getMotherBoard(); |
| 25 |
assert(motherboard); |
| 26 |
std::string slotName; |
| 27 |
if (option.size() == 5) { |
| 28 |
slotName = option[4]; |
| 29 |
} else { |
| 30 |
slotName = "any"; |
| 31 |
} |
| 32 |
motherboard->insertExtension(extensionName, |
| 33 |
motherboard->loadExtension(extensionName, slotName)); |
| 34 |
} catch (MSXException& e) { |
| 35 |
throw FatalError(std::move(e).getMessage()); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
std::string_view CliExtension::optionHelp() const |
| 40 |
{ |
| 41 |
return "Insert the extension specified in argument"; |
| 42 |
} |
| 43 |
|
| 44 |
} |