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
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
std::string_view optionHelp() const override
Definition: ReplayCLI.cc:21
std::string_view fileTypeCategoryName() const override
Definition: ReplayCLI.cc:38
void parseOption(const std::string &option, span< std::string > &cmdLine) override
Definition: ReplayCLI.cc:16
ReplayCLI(CommandLineParser &parser)
Definition: ReplayCLI.cc:9
void parseFileType(const std::string &filename, span< std::string > &cmdLine) override
Definition: ReplayCLI.cc:26
std::string_view fileTypeHelp() const override
Definition: ReplayCLI.cc:33
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