openMSX
LaserdiscPlayerCLI.cc
Go to the documentation of this file.
1 #include "LaserdiscPlayerCLI.hh"
2 #include "CommandLineParser.hh"
4 #include "MSXException.hh"
5 #include "TclObject.hh"
6 
7 using std::string;
8 
9 namespace openmsx {
10 
12  : parser(parser_)
13 {
14  parser.registerOption("-laserdisc", *this);
15  parser.registerFileType({"ogv"}, *this);
16 }
17 
18 void LaserdiscPlayerCLI::parseOption(const string& option, span<string>& cmdLine)
19 {
20  parseFileType(getArgument(option, cmdLine), cmdLine);
21 }
22 
23 std::string_view LaserdiscPlayerCLI::optionHelp() const
24 {
25  return "Put LaserDisc image specified in argument in "
26  "virtual LaserDisc player";
27 }
28 
30  span<string>& /*cmdLine*/)
31 {
32  if (!parser.getGlobalCommandController().hasCommand("laserdiscplayer")) {
33  throw MSXException("No LaserDisc player present.");
34  }
35  TclObject command = makeTclList("laserdiscplayer", "insert", filename);
36  command.executeCommand(parser.getInterpreter());
37 }
38 
39 std::string_view LaserdiscPlayerCLI::fileTypeHelp() const
40 {
41  return "LaserDisc image, Ogg Vorbis/Theora";
42 }
43 
45 {
46  return "laserdisc";
47 }
48 
49 } // namespace openmsx
LaserdiscPlayerCLI.hh
openmsx::CommandLineParser::registerOption
void registerOption(const char *str, CLIOption &cliOption, ParsePhase phase=PHASE_LAST, unsigned length=2)
Definition: CommandLineParser.cc:84
TclObject.hh
openmsx::CommandLineParser::getInterpreter
Interpreter & getInterpreter() const
Definition: CommandLineParser.cc:306
openmsx::GlobalCommandController::hasCommand
bool hasCommand(std::string_view command) const override
Does a command with this name already exist?
Definition: GlobalCommandController.cc:174
CommandLineParser.hh
MSXException.hh
openmsx::MSXException
Definition: MSXException.hh:10
openmsx::LaserdiscPlayerCLI::parseFileType
void parseFileType(const std::string &filename, span< std::string > &cmdLine) override
Definition: LaserdiscPlayerCLI.cc:29
span
Definition: span.hh:34
openmsx::filename
constexpr const char *const filename
Definition: FirmwareSwitch.cc:10
openmsx::TclObject::executeCommand
TclObject executeCommand(Interpreter &interp, bool compile=false)
Interpret this TclObject as a command and execute it.
Definition: TclObject.cc:172
openmsx::CommandLineParser
Definition: CommandLineParser.hh:35
openmsx::LaserdiscPlayerCLI::LaserdiscPlayerCLI
LaserdiscPlayerCLI(CommandLineParser &parser)
Definition: LaserdiscPlayerCLI.cc:11
GlobalCommandController.hh
openmsx::makeTclList
TclObject makeTclList(Args &&... args)
Definition: TclObject.hh:280
openmsx::LaserdiscPlayerCLI::optionHelp
std::string_view optionHelp() const override
Definition: LaserdiscPlayerCLI.cc:23
openmsx::TclObject
Definition: TclObject.hh:22
openmsx::CommandLineParser::getGlobalCommandController
GlobalCommandController & getGlobalCommandController() const
Definition: CommandLineParser.cc:301
openmsx::CommandLineParser::registerFileType
void registerFileType(std::initializer_list< std::string_view > extensions, CLIFileType &cliFileType)
Definition: CommandLineParser.cc:90
openmsx::CLIOption::getArgument
std::string getArgument(const std::string &option, span< std::string > &cmdLine) const
Definition: CLIOption.cc:11
openmsx::LaserdiscPlayerCLI::parseOption
void parseOption(const std::string &option, span< std::string > &cmdLine) override
Definition: LaserdiscPlayerCLI.cc:18
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::LaserdiscPlayerCLI::fileTypeCategoryName
std::string_view fileTypeCategoryName() const override
Definition: LaserdiscPlayerCLI.cc:44
openmsx::LaserdiscPlayerCLI::fileTypeHelp
std::string_view fileTypeHelp() const override
Definition: LaserdiscPlayerCLI.cc:39