openMSX
CassettePlayerCLI.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("-cassetteplayer", *this);
13 parser.registerFileType({"cas", "wav"}, *this);
14}
15
16void CassettePlayerCLI::parseOption(const std::string& option,
17 std::span<std::string>& cmdLine)
18{
19 parseFileType(getArgument(option, cmdLine), cmdLine);
20}
21
22std::string_view CassettePlayerCLI::optionHelp() const
23{
24 return "Put cassette image specified in argument in "
25 "virtual cassetteplayer";
26}
27
28void CassettePlayerCLI::parseFileType(const std::string& filename,
29 std::span<std::string>& /*cmdLine*/)
30{
31 if (!parser.getInterpreter().hasCommand("cassetteplayer")) {
32 throw MSXException("No cassette player present.");
33 }
34 TclObject command = makeTclList("cassetteplayer", filename);
35 command.executeCommand(parser.getInterpreter());
36}
37
38std::string_view CassettePlayerCLI::fileTypeHelp() const
39{
40 return "Cassette image, raw recording or fMSX CAS image";
41}
42
44{
45 return "cassette";
46}
47
48} // namespace openmsx
static std::string getArgument(const std::string &option, std::span< std::string > &cmdLine)
Definition: CLIOption.cc:9
CassettePlayerCLI(CommandLineParser &parser)
void parseOption(const std::string &option, std::span< std::string > &cmdLine) override
std::string_view fileTypeCategoryName() const override
void parseFileType(const std::string &filename, std::span< std::string > &cmdLine) override
std::string_view fileTypeHelp() const override
std::string_view optionHelp() const override
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:149
TclObject executeCommand(Interpreter &interp, bool compile=false)
Interpret this TclObject as a command and execute it.
Definition: TclObject.cc:190
This file implemented 3 utility functions:
Definition: Autofire.cc:9
TclObject makeTclList(Args &&... args)
Definition: TclObject.hh:283