openMSX
ReplayCLI.cc
Go to the documentation of this file.
1 #include "ReplayCLI.hh"
2 #include "CommandLineParser.hh"
3 #include "TclObject.hh"
4 
5 using std::string;
6 
7 namespace openmsx {
8 
10  : parser(parser_)
11 {
12  parser.registerOption("-replay", *this);
13  parser.registerFileType({"omr"}, *this);
14 }
15 
16 void ReplayCLI::parseOption(const string& option, span<string>& cmdLine)
17 {
18  parseFileType(getArgument(option, cmdLine), cmdLine);
19 }
20 
21 std::string_view ReplayCLI::optionHelp() const
22 {
23  return "Load replay and start replaying it in view only mode";
24 }
25 
27  span<string>& /*cmdLine*/)
28 {
29  TclObject command = makeTclList("reverse", "loadreplay", "-viewonly", filename);
30  command.executeCommand(parser.getInterpreter());
31 }
32 
33 std::string_view ReplayCLI::fileTypeHelp() const
34 {
35  return "openMSX replay";
36 }
37 
38 std::string_view ReplayCLI::fileTypeCategoryName() const
39 {
40  return "replay";
41 }
42 
43 } // namespace openmsx
openmsx::ReplayCLI::parseOption
void parseOption(const std::string &option, span< std::string > &cmdLine) override
Definition: ReplayCLI.cc:16
openmsx::ReplayCLI::fileTypeCategoryName
std::string_view fileTypeCategoryName() const override
Definition: ReplayCLI.cc:38
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
CommandLineParser.hh
openmsx::ReplayCLI::optionHelp
std::string_view optionHelp() const override
Definition: ReplayCLI.cc:21
ReplayCLI.hh
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::makeTclList
TclObject makeTclList(Args &&... args)
Definition: TclObject.hh:280
openmsx::ReplayCLI::fileTypeHelp
std::string_view fileTypeHelp() const override
Definition: ReplayCLI.cc:33
openmsx::TclObject
Definition: TclObject.hh:22
openmsx::ReplayCLI::ReplayCLI
ReplayCLI(CommandLineParser &parser)
Definition: ReplayCLI.cc:9
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::ReplayCLI::parseFileType
void parseFileType(const std::string &filename, span< std::string > &cmdLine) override
Definition: ReplayCLI.cc:26
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5