openMSX
CDImageCLI.cc
Go to the documentation of this file.
1#include "CDImageCLI.hh"
3#include "Interpreter.hh"
4#include "TclObject.hh"
5#include "MSXException.hh"
6
7namespace openmsx {
8
10 : parser(parser_)
11{
12 parser.registerOption("-cda", *this);
13 // TODO: offer more options in case you want to specify 2 hard disk images?
14}
15
16void CDImageCLI::parseOption(const std::string& option, std::span<std::string>& cmdLine)
17{
18 auto cd = std::string_view(option).substr(1); // cda
19 std::string filename = getArgument(option, cmdLine);
20 if (!parser.getInterpreter().hasCommand(std::string(cd))) { // TODO WIP
21 throw MSXException("No CD-ROM named '", cd, "'.");
22 }
23 TclObject command = makeTclList(cd, filename);
24 command.executeCommand(parser.getInterpreter());
25}
26std::string_view CDImageCLI::optionHelp() const
27{
28 return "Use iso image in argument for the CD-ROM extension";
29}
30
31} // namespace openmsx
std::string_view optionHelp() const override
Definition CDImageCLI.cc:26
void parseOption(const std::string &option, std::span< std::string > &cmdLine) override
Definition CDImageCLI.cc:16
CDImageCLI(CommandLineParser &parser)
Definition CDImageCLI.cc:9
static std::string getArgument(const std::string &option, std::span< std::string > &cmdLine)
Definition CLIOption.cc:9
void registerOption(const char *str, CLIOption &cliOption, ParsePhase phase=PHASE_LAST, unsigned length=2)
Interpreter & getInterpreter() const
bool hasCommand(zstring_view name) const
TclObject executeCommand(Interpreter &interp, bool compile=false)
Interpret this TclObject as a command and execute it.
Definition TclObject.cc:248
This file implemented 3 utility functions:
Definition Autofire.cc:11
TclObject makeTclList(Args &&... args)
Definition TclObject.hh:293