1#ifndef COMMANDLINEPARSER_HH
2#define COMMANDLINEPARSER_HH
15#include <initializer_list>
23#if COMPONENT_LASERDISC
31class GlobalCommandController;
54 void parse(std::span<char*> argv);
58 return scriptOption.scripts;
61 return commandOption.commands;
74 std::string_view name;
80 std::string_view extension;
81 CLIFileType* fileType;
84 [[nodiscard]]
bool parseFileName(
const std::string& arg,
85 std::span<std::string>& cmdLine);
86 [[nodiscard]] CLIFileType* getFileTypeHandlerForFileName(std::string_view filename)
const;
87 [[nodiscard]]
bool parseOption(
const std::string& arg,
88 std::span<std::string>& cmdLine,
ParsePhase phase);
89 void createMachineSetting();
92 std::vector<OptionData> options;
93 std::vector<FileTypeData> fileTypes;
97 struct HelpOption final : CLIOption {
98 void parseOption(
const std::string& option, std::span<std::string>& cmdLine)
override;
99 [[nodiscard]] std::string_view optionHelp()
const override;
102 struct VersionOption final : CLIOption {
103 void parseOption(
const std::string& option, std::span<std::string>& cmdLine)
override;
104 [[nodiscard]] std::string_view optionHelp()
const override;
107 struct ControlOption final : CLIOption {
108 void parseOption(
const std::string& option, std::span<std::string>& cmdLine)
override;
109 [[nodiscard]] std::string_view optionHelp()
const override;
112 struct ScriptOption final : CLIOption, CLIFileType {
113 void parseOption(
const std::string& option, std::span<std::string>& cmdLine)
override;
114 [[nodiscard]] std::string_view optionHelp()
const override;
115 void parseFileType(
const std::string& filename,
116 std::span<std::string>& cmdLine)
override;
117 [[nodiscard]] std::string_view fileTypeCategoryName()
const override;
118 [[nodiscard]] std::string_view fileTypeHelp()
const override;
120 std::vector<std::string> scripts;
123 struct CommandOption final : CLIOption {
124 void parseOption(
const std::string& option, std::span<std::string>& cmdLine)
override;
125 [[nodiscard]] std::string_view optionHelp()
const override;
127 std::vector<std::string> commands;
130 struct MachineOption final : CLIOption {
131 void parseOption(
const std::string& option, std::span<std::string>& cmdLine)
override;
132 [[nodiscard]] std::string_view optionHelp()
const override;
135 struct SettingOption final : CLIOption {
136 void parseOption(
const std::string& option, std::span<std::string>& cmdLine)
override;
137 [[nodiscard]] std::string_view optionHelp()
const override;
140 struct TestConfigOption final : CLIOption {
141 void parseOption(
const std::string& option, std::span<std::string>& cmdLine)
override;
142 [[nodiscard]] std::string_view optionHelp()
const override;
145 struct BashOption final : CLIOption {
146 void parseOption(
const std::string& option, std::span<std::string>& cmdLine)
override;
147 [[nodiscard]] std::string_view optionHelp()
const override;
150 struct FileTypeCategoryInfoTopic final : InfoTopic {
151 FileTypeCategoryInfoTopic(InfoCommand& openMSXInfoCommand,
const CommandLineParser& parser);
152 void execute(std::span<const TclObject> tokens, TclObject& result)
const override;
153 [[nodiscard]] std::string help(std::span<const TclObject> tokens)
const override;
157 std::optional<FileTypeCategoryInfoTopic> fileTypeCategoryInfo;
160 CliExtension cliExtension;
162 SaveStateCLI saveStateCLI;
163 CassettePlayerCLI cassettePlayerCLI;
164#if COMPONENT_LASERDISC
165 LaserdiscPlayerCLI laserdiscPlayerCLI;
167 DiskImageCLI diskImageCLI;
168 HDImageCLI hdImageCLI;
169 CDImageCLI cdImageCLI;
171 bool haveConfig =
false;
172 bool haveSettings =
false;
CommandLineParser(Reactor &reactor)
bool isHiddenStartup() const
Need to suppress renderer window on startup?
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)
const auto & getStartupScripts() const
ParseStatus getParseStatus() const
void parse(std::span< char * > argv)
const auto & getStartupCommands() const
GlobalCommandController & getGlobalCommandController() const
Interpreter & getInterpreter() const
MSXMotherBoard * getMotherBoard() const
Contains the main loop of openMSX.
T length(const vecN< N, T > &x)
This file implemented 3 utility functions: