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