openMSX
LaserdiscPlayerCLI.cc
Go to the documentation of this file.
3#include "Interpreter.hh"
4#include "MSXException.hh"
5#include "TclObject.hh"
6
7namespace openmsx {
8
10 : parser(parser_)
11{
12 parser.registerOption("-laserdisc", *this);
13 parser.registerFileType(std::array<std::string_view, 1>{"ogv"}, *this);
14}
15
16void LaserdiscPlayerCLI::parseOption(const std::string& option, std::span<std::string>& cmdLine)
17{
18 parseFileType(getArgument(option, cmdLine), cmdLine);
19}
20
21std::string_view LaserdiscPlayerCLI::optionHelp() const
22{
23 return "Put LaserDisc image specified in argument in "
24 "virtual LaserDisc player";
25}
26
27void LaserdiscPlayerCLI::parseFileType(const std::string& filename,
28 std::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
37std::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, std::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::span< const std::string_view > extensions, CLIFileType &cliFileType)
Interpreter & getInterpreter() const
bool hasCommand(zstring_view name) const
void parseOption(const std::string &option, std::span< std::string > &cmdLine) override
std::string_view fileTypeHelp() const override
LaserdiscPlayerCLI(CommandLineParser &parser)
void parseFileType(const std::string &filename, std::span< std::string > &cmdLine) override
std::string_view fileTypeCategoryName() const 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:249
This file implemented 3 utility functions:
Definition Autofire.cc:11
TclObject makeTclList(Args &&... args)
Definition TclObject.hh:293