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