openMSX
CliExtension.cc
Go to the documentation of this file.
1#include "CliExtension.hh"
3#include "MSXMotherBoard.hh"
4#include "MSXException.hh"
5#include <cassert>
6
7namespace openmsx {
8
10 : cmdLineParser(cmdLineParser_)
11{
12 cmdLineParser.registerOption("-ext", *this);
13 cmdLineParser.registerOption("-exta", *this);
14 cmdLineParser.registerOption("-extb", *this);
15 cmdLineParser.registerOption("-extc", *this);
16 cmdLineParser.registerOption("-extd", *this);
17}
18
19void CliExtension::parseOption(const std::string& option, std::span<std::string>& cmdLine)
20{
21 try {
22 std::string extensionName = getArgument(option, cmdLine);
23 MSXMotherBoard* motherboard = cmdLineParser.getMotherBoard();
24 assert(motherboard);
25 std::string slotName;
26 if (option.size() == 5) {
27 slotName = option[4];
28 } else {
29 slotName = "any";
30 }
31 motherboard->loadExtension(extensionName, slotName);
32 } catch (MSXException& e) {
33 throw FatalError(std::move(e).getMessage());
34 }
35}
36
37std::string_view CliExtension::optionHelp() const
38{
39 return "Insert the extension specified in argument";
40}
41
42} // namespace openmsx
static std::string getArgument(const std::string &option, std::span< std::string > &cmdLine)
Definition: CLIOption.cc:9
CliExtension(CommandLineParser &cmdLineParser)
Definition: CliExtension.cc:9
std::string_view optionHelp() const override
Definition: CliExtension.cc:37
void parseOption(const std::string &option, std::span< std::string > &cmdLine) override
Definition: CliExtension.cc:19
void registerOption(const char *str, CLIOption &cliOption, ParsePhase phase=PHASE_LAST, unsigned length=2)
MSXMotherBoard * getMotherBoard() const
std::string loadExtension(std::string_view extensionName, std::string_view slotName)
constexpr double e
Definition: Math.hh:21
This file implemented 3 utility functions:
Definition: Autofire.cc:9