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 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.getInterpreter().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
static std::string getArgument(const std::string &option, span< std::string > &cmdLine)
Definition: CLIOption.cc:11
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:145
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:291