openMSX
CommandLineParser.cc
Go to the documentation of this file.
1 #include "CommandLineParser.hh"
2 #include "CLIOption.hh"
4 #include "Interpreter.hh"
5 #include "SettingsConfig.hh"
6 #include "File.hh"
7 #include "FileContext.hh"
8 #include "FileOperations.hh"
9 #include "GlobalCliComm.hh"
10 #include "StdioMessages.hh"
11 #include "Version.hh"
12 #include "MSXRomCLI.hh"
13 #include "CliExtension.hh"
14 #include "CliConnection.hh"
15 #include "ReplayCLI.hh"
16 #include "SaveStateCLI.hh"
17 #include "CassettePlayerCLI.hh"
18 #include "DiskImageCLI.hh"
19 #include "HDImageCLI.hh"
20 #include "CDImageCLI.hh"
21 #include "ConfigException.hh"
22 #include "FileException.hh"
23 #include "EnumSetting.hh"
24 #include "XMLException.hh"
25 #include "StringOp.hh"
26 #include "xrange.hh"
27 #include "GLUtil.hh"
28 #include "Reactor.hh"
29 #include "RomInfo.hh"
30 #include "StringMap.hh"
31 #include "memory.hh"
32 #include "stl.hh"
33 #include "build-info.hh"
34 #include "components.hh"
35 
36 #if COMPONENT_LASERDISC
37 #include "LaserdiscPlayerCLI.hh"
38 #endif
39 
40 #include <cassert>
41 #include <iostream>
42 
43 using std::cout;
44 using std::endl;
45 using std::string;
46 using std::vector;
47 
48 namespace openmsx {
49 
50 class HelpOption : public CLIOption
51 {
52 public:
53  explicit HelpOption(CommandLineParser& parser);
54  virtual void parseOption(const string& option, array_ref<string>& cmdLine);
55  virtual string_ref optionHelp() const;
56 private:
57  CommandLineParser& parser;
58 };
59 
60 class VersionOption : public CLIOption
61 {
62 public:
63  explicit VersionOption(CommandLineParser& parser);
64  virtual void parseOption(const string& option, array_ref<string>& cmdLine);
65  virtual string_ref optionHelp() const;
66 private:
67  CommandLineParser& parser;
68 };
69 
70 class ControlOption : public CLIOption
71 {
72 public:
73  explicit ControlOption(CommandLineParser& parser);
74  virtual void parseOption(const string& option, array_ref<string>& cmdLine);
75  virtual string_ref optionHelp() const;
76 private:
77  CommandLineParser& parser;
78 };
79 
80 class ScriptOption : public CLIOption, public CLIFileType
81 {
82 public:
84  virtual void parseOption(const string& option, array_ref<string>& cmdLine);
85  virtual string_ref optionHelp() const;
86  virtual void parseFileType(const std::string& filename,
87  array_ref<std::string>& cmdLine);
88  virtual string_ref fileTypeHelp() const;
89 
90 private:
92 };
93 
94 class MachineOption : public CLIOption
95 {
96 public:
97  explicit MachineOption(CommandLineParser& parser);
98  virtual void parseOption(const string& option, array_ref<string>& cmdLine);
99  virtual string_ref optionHelp() const;
100 private:
101  CommandLineParser& parser;
102 };
103 
104 class SettingOption : public CLIOption
105 {
106 public:
107  explicit SettingOption(CommandLineParser& parser);
108  virtual void parseOption(const string& option, array_ref<string>& cmdLine);
109  virtual string_ref optionHelp() const;
110 private:
111  CommandLineParser& parser;
112 };
113 
114 class NoPBOOption : public CLIOption {
115 public:
116  virtual void parseOption(const string& option, array_ref<string>& cmdLine);
117  virtual string_ref optionHelp() const;
118 };
119 
121 {
122 public:
123  explicit TestConfigOption(CommandLineParser& parser);
124  virtual void parseOption(const string& option, array_ref<string>& cmdLine);
125  virtual string_ref optionHelp() const;
126 private:
127  CommandLineParser& parser;
128 };
129 
130 class BashOption : public CLIOption
131 {
132 public:
133  explicit BashOption(CommandLineParser& parser);
134  virtual void parseOption(const string& option, array_ref<string>& cmdLine);
135  virtual string_ref optionHelp() const;
136 private:
137  CommandLineParser& parser;
138 };
139 
140 
141 // class CommandLineParser
142 
145 
147  : reactor(reactor_)
148  , helpOption(make_unique<HelpOption>(*this))
149  , versionOption(make_unique<VersionOption>(*this))
150  , controlOption(make_unique<ControlOption>(*this))
151  , scriptOption(make_unique<ScriptOption>())
152  , machineOption(make_unique<MachineOption>(*this))
153  , settingOption(make_unique<SettingOption>(*this))
154  , noPBOOption(make_unique<NoPBOOption>())
155  , testConfigOption(make_unique<TestConfigOption>(*this))
156  , bashOption(make_unique<BashOption>(*this))
157  , msxRomCLI(make_unique<MSXRomCLI>(*this))
158  , cliExtension(make_unique<CliExtension>(*this))
159  , replayCLI(make_unique<ReplayCLI>(*this))
160  , saveStateCLI(make_unique<SaveStateCLI>(*this))
161  , cassettePlayerCLI(make_unique<CassettePlayerCLI>(*this))
163  , laserdiscPlayerCLI(make_unique<LaserdiscPlayerCLI>(*this))
164 #endif
165  , diskImageCLI(make_unique<DiskImageCLI>(*this))
166  , hdImageCLI(make_unique<HDImageCLI>(*this))
167  , cdImageCLI(make_unique<CDImageCLI>(*this))
168  , parseStatus(UNPARSED)
169 {
170  haveConfig = false;
171  haveSettings = false;
172 
173  registerOption("-h", *helpOption, PHASE_BEFORE_INIT, 1);
174  registerOption("--help", *helpOption, PHASE_BEFORE_INIT, 1);
175  registerOption("-v", *versionOption, PHASE_BEFORE_INIT, 1);
176  registerOption("--version", *versionOption, PHASE_BEFORE_INIT, 1);
177  registerOption("-bash", *bashOption, PHASE_BEFORE_INIT, 1);
178 
179  registerOption("-setting", *settingOption, PHASE_BEFORE_SETTINGS);
180  registerOption("-control", *controlOption, PHASE_BEFORE_SETTINGS, 1);
181  registerOption("-script", *scriptOption, PHASE_BEFORE_SETTINGS, 1); // correct phase?
182  #if COMPONENT_GL
183  registerOption("-nopbo", *noPBOOption, PHASE_BEFORE_SETTINGS, 1);
184  #endif
185  registerOption("-testconfig", *testConfigOption, PHASE_BEFORE_SETTINGS, 1);
186 
187  registerOption("-machine", *machineOption, PHASE_BEFORE_MACHINE);
188 
189  registerFileType("tcl", *scriptOption);
190 
191  // At this point all options and file-types must be registered
192  sort(begin(options), end(options), CmpOptions());
193  sort(begin(fileTypes), end(fileTypes), CmpFileTypes());
194 }
195 
197 {
198 }
199 
201  const char* str, CLIOption& cliOption, ParsePhase phase, unsigned length)
202 {
203  options.emplace_back(str, OptionData{&cliOption, phase, length});
204 }
205 
207  string_ref extensions, CLIFileType& cliFileType)
208 {
209  for (auto& ext: StringOp::split(extensions, ',')) {
210  fileTypes.emplace_back(ext, &cliFileType);
211  }
212 }
213 
214 bool CommandLineParser::parseOption(
215  const string& arg, array_ref<string>& cmdLine, ParsePhase phase)
216 {
217  auto it = lower_bound(begin(options), end(options), arg, CmpOptions());
218  if ((it != end(options)) && (it->first == arg)) {
219  // parse option
220  if (it->second.phase <= phase) {
221  try {
222  it->second.option->parseOption(arg, cmdLine);
223  return true;
224  } catch (MSXException& e) {
225  throw FatalError(e.getMessage());
226  }
227  }
228  }
229  return false; // unknown
230 }
231 
232 bool CommandLineParser::parseFileName(const string& arg, array_ref<string>& cmdLine)
233 {
234  // First try the fileName as we get it from the commandline. This may
235  // be more interesting than the original fileName of a (g)zipped file:
236  // in case of an OMR file for instance, we want to select on the
237  // original extension, and not on the extension inside the gzipped
238  // file.
239  bool processed = parseFileNameInner(arg, arg, cmdLine);
240  if (!processed) {
241  try {
242  File file(UserFileContext().resolve(arg));
243  string originalName = file.getOriginalName();
244  processed = parseFileNameInner(originalName, arg, cmdLine);
245  } catch (FileException&) {
246  // ignore
247  }
248  }
249  return processed;
250 }
251 
252 bool CommandLineParser::parseFileNameInner(const string& name, const string& originalPath, array_ref<string>& cmdLine)
253 {
254  string_ref extension = FileOperations::getExtension(name);
255  if (extension.empty()) {
256  return false; // no extension
257  }
258 
259  auto it = lower_bound(begin(fileTypes), end(fileTypes), extension,
260  CmpFileTypes());
261  StringOp::casecmp cmp;
262  if ((it == end(fileTypes)) || !cmp(it->first, extension)) {
263  return false; // unknown extension
264  }
265 
266  try {
267  // parse filetype
268  it->second->parseFileType(originalPath, cmdLine);
269  return true; // file processed
270  } catch (MSXException& e) {
271  throw FatalError(e.getMessage());
272  }
273 }
274 
275 void CommandLineParser::parse(int argc, char** argv)
276 {
277  parseStatus = RUN;
278 
279  vector<string> cmdLineBuf;
280  for (auto i : xrange(1, argc)) {
281  cmdLineBuf.push_back(FileOperations::getConventionalPath(argv[i]));
282  }
283  array_ref<string> cmdLine(cmdLineBuf);
284  vector<string> backupCmdLine;
285 
286  for (ParsePhase phase = PHASE_BEFORE_INIT;
287  (phase <= PHASE_LAST) && (parseStatus != EXIT);
288  phase = static_cast<ParsePhase>(phase + 1)) {
289  switch (phase) {
290  case PHASE_INIT:
291  reactor.init();
292  getInterpreter().init(argv[0]);
293  break;
294  case PHASE_LOAD_SETTINGS:
295  // after -control and -setting has been parsed
296  if (parseStatus != CONTROL) {
297  // if there already is a XML-StdioConnection, we
298  // can't also show plain messages on stdout
299  auto& cliComm = reactor.getGlobalCliComm();
300  cliComm.addListener(new StdioMessages());
301  }
302  if (!haveSettings) {
303  auto& settingsConfig =
305  // Load default settings file in case the user
306  // didn't specify one.
308  string filename = "settings.xml";
309  try {
310  settingsConfig.loadSetting(context, filename);
311  } catch (XMLException& e) {
312  reactor.getCliComm().printWarning(
313  "Loading of settings failed: " +
314  e.getMessage() + "\n"
315  "Reverting to default settings.");
316  } catch (FileException&) {
317  // settings.xml not found
318  } catch (ConfigException& e) {
319  throw FatalError("Error in default settings: "
320  + e.getMessage());
321  }
322  // Consider an attempt to load the settings good enough.
323  haveSettings = true;
324  // Even if parsing failed, use this file for saving,
325  // this forces overwriting a non-setting file.
326  settingsConfig.setSaveFilename(context, filename);
327  }
328  break;
329  case PHASE_LOAD_MACHINE: {
330  if (!haveConfig) {
331  // load default config file in case the user didn't specify one
332  const auto& machine =
333  reactor.getMachineSetting().getString();
334  try {
335  reactor.switchMachine(machine);
336  } catch (MSXException& e) {
337  reactor.getCliComm().printInfo(
338  "Failed to initialize default machine: " + e.getMessage());
339  // Default machine is broken; fall back to C-BIOS config.
340  const auto& fallbackMachine =
342  reactor.getCliComm().printInfo("Using fallback machine: " + fallbackMachine);
343  try {
344  reactor.switchMachine(fallbackMachine);
345  } catch (MSXException& e2) {
346  // Fallback machine failed as well; we're out of options.
347  throw FatalError(e2.getMessage());
348  }
349  }
350  haveConfig = true;
351  }
352  break;
353  }
354  default:
355  // iterate over all arguments
356  while (!cmdLine.empty()) {
357  string arg = std::move(cmdLine.front());
358  cmdLine.pop_front();
359  // first try options
360  if (!parseOption(arg, cmdLine, phase)) {
361  // next try the registered filetypes (xml)
362  if ((phase != PHASE_LAST) ||
363  !parseFileName(arg, cmdLine)) {
364  // no option or known file
365  backupCmdLine.push_back(arg);
366  auto it = lower_bound(begin(options), end(options), arg, CmpOptions());
367  if ((it != end(options)) && (it->first == arg)) {
368  for (unsigned i = 0; i < it->second.length - 1; ++i) {
369  if (!cmdLine.empty()) {
370  backupCmdLine.push_back(std::move(cmdLine.front()));
371  cmdLine.pop_front();
372  }
373  }
374  }
375  }
376  }
377  }
378  std::swap(backupCmdLine, cmdLineBuf);
379  backupCmdLine.clear();
380  cmdLine = cmdLineBuf;
381  break;
382  }
383  }
384  if (!cmdLine.empty() && (parseStatus != EXIT)) {
385  throw FatalError(
386  "Error parsing command line: " + cmdLine.front() + "\n" +
387  "Use \"openmsx -h\" to see a list of available options" );
388  }
389 
390  hiddenStartup = (parseStatus == CONTROL || parseStatus == TEST );
391 }
392 
394 {
395  return hiddenStartup;
396 }
397 
399 {
400  assert(parseStatus != UNPARSED);
401  return parseStatus;
402 }
403 
405 {
406  return scriptOption->getScripts();
407 }
408 
410 {
411  return reactor.getMotherBoard();
412 }
413 
415 {
416  return reactor.getGlobalCommandController();
417 }
418 
420 {
421  return reactor.getInterpreter();
422 }
423 
424 
425 // Control option
426 
428  : parser(parser_)
429 {
430 }
431 
432 void ControlOption::parseOption(const string& option, array_ref<string>& cmdLine)
433 {
434  const auto& fullType = getArgument(option, cmdLine);
435  string_ref type, arguments;
436  StringOp::splitOnFirst(fullType, ':', type, arguments);
437 
438  auto& controller = parser.getGlobalCommandController();
439  auto& distributor = parser.reactor.getEventDistributor();
440  auto& cliComm = parser.reactor.getGlobalCliComm();
441  std::unique_ptr<CliListener> connection;
442  if (type == "stdio") {
443  connection = make_unique<StdioConnection>(
444  controller, distributor);
445 #ifdef _WIN32
446  } else if (type == "pipe") {
447  OSVERSIONINFO info;
448  info.dwOSVersionInfoSize = sizeof(info);
449  GetVersionEx(&info);
450  if (info.dwPlatformId == VER_PLATFORM_WIN32_NT) {
451  connection = make_unique<PipeConnection>(
452  controller, distributor, arguments);
453  } else {
454  throw FatalError("Pipes are not supported on this "
455  "version of Windows");
456  }
457 #endif
458  } else {
459  throw FatalError("Unknown control type: '" + type + '\'');
460  }
461  cliComm.addListener(connection.release());
462 
463  parser.parseStatus = CommandLineParser::CONTROL;
464 }
465 
467 {
468  return "Enable external control of openMSX process";
469 }
470 
471 
472 // Script option
473 
475 {
476  return scripts;
477 }
478 
479 void ScriptOption::parseOption(const string& option, array_ref<string>& cmdLine)
480 {
481  parseFileType(getArgument(option, cmdLine), cmdLine);
482 }
483 
485 {
486  return "Run extra startup script";
487 }
488 
489 void ScriptOption::parseFileType(const string& filename,
490  array_ref<std::string>& /*cmdLine*/)
491 {
492  scripts.push_back(filename);
493 }
494 
496 {
497  return "Extra Tcl script to run at startup";
498 }
499 
500 // Help option
501 
502 static string formatSet(const vector<string_ref>& inputSet, string::size_type columns)
503 {
504  StringOp::Builder outString;
505  string::size_type totalLength = 0; // ignore the starting spaces for now
506  for (auto& temp : inputSet) {
507  if (totalLength == 0) {
508  // first element ?
509  outString << " " << temp;
510  totalLength = temp.size();
511  } else {
512  outString << ", ";
513  if ((totalLength + temp.size()) > columns) {
514  outString << "\n " << temp;
515  totalLength = temp.size();
516  } else {
517  outString << temp;
518  totalLength += 2 + temp.size();
519  }
520  }
521  }
522  if (totalLength < columns) {
523  outString << string(columns - totalLength, ' ');
524  }
525  return outString;
526 }
527 
528 static string formatHelptext(string_ref helpText,
529  unsigned maxLength, unsigned indent)
530 {
531  string outText;
532  string_ref::size_type index = 0;
533  while (helpText.substr(index).size() > maxLength) {
534  auto pos = helpText.substr(index, maxLength).rfind(' ');
535  if (pos == string_ref::npos) {
536  pos = helpText.substr(maxLength).find(' ');
537  if (pos == string_ref::npos) {
538  pos = helpText.substr(index).size();
539  }
540  }
541  outText += helpText.substr(index, index + pos) + '\n' +
542  string(indent, ' ');
543  index = pos + 1;
544  }
545  string_ref t = helpText.substr(index);
546  outText.append(t.data(), t.size());
547  return outText;
548 }
549 
550 static void printItemMap(const StringMap<vector<string_ref>>& itemMap)
551 {
552  vector<string> printSet;
553  for (auto& p : itemMap) {
554  printSet.push_back(formatSet(p.second, 15) + ' ' +
555  formatHelptext(p.first(), 50, 20));
556  }
557  sort(begin(printSet), end(printSet));
558  for (auto& s : printSet) {
559  cout << s << endl;
560  }
561 }
562 
564  : parser(parser_)
565 {
566 }
567 
568 void HelpOption::parseOption(const string& /*option*/,
569  array_ref<string>& /*cmdLine*/)
570 {
571  const auto& fullVersion = Version::full();
572  cout << fullVersion << endl;
573  cout << string(fullVersion.size(), '=') << endl;
574  cout << endl;
575  cout << "usage: openmsx [arguments]" << endl;
576  cout << " an argument is either an option or a filename" << endl;
577  cout << endl;
578  cout << " this is the list of supported options:" << endl;
579 
580  StringMap<vector<string_ref>> optionMap;
581  for (auto& p : parser.options) {
582  const auto& helpText = p.second.option->optionHelp();
583  if (!helpText.empty()) {
584  optionMap[helpText].push_back(p.first);
585  }
586  }
587  printItemMap(optionMap);
588 
589  cout << endl;
590  cout << " this is the list of supported file types:" << endl;
591 
593  for (auto& p : parser.fileTypes) {
594  extMap[p.second->fileTypeHelp()].push_back(p.first);
595  }
596  printItemMap(extMap);
597 
598  parser.parseStatus = CommandLineParser::EXIT;
599 }
600 
602 {
603  return "Shows this text";
604 }
605 
606 
607 // class VersionOption
608 
610  : parser(parser_)
611 {
612 }
613 
614 void VersionOption::parseOption(const string& /*option*/,
615  array_ref<string>& /*cmdLine*/)
616 {
617  cout << Version::full() << endl;
618  cout << "flavour: " << BUILD_FLAVOUR << endl;
619  cout << "components: " << BUILD_COMPONENTS << endl;
620  parser.parseStatus = CommandLineParser::EXIT;
621 }
622 
624 {
625  return "Prints openMSX version and exits";
626 }
627 
628 
629 // Machine option
630 
632  : parser(parser_)
633 {
634 }
635 
636 void MachineOption::parseOption(const string& option, array_ref<string>& cmdLine)
637 {
638  if (parser.haveConfig) {
639  throw FatalError("Only one machine option allowed");
640  }
641  try {
642  parser.reactor.switchMachine(getArgument(option, cmdLine));
643  } catch (MSXException& e) {
644  throw FatalError(e.getMessage());
645  }
646  parser.haveConfig = true;
647 }
649 {
650  return "Use machine specified in argument";
651 }
652 
653 
654 // Setting Option
655 
657  : parser(parser_)
658 {
659 }
660 
661 void SettingOption::parseOption(const string& option, array_ref<string>& cmdLine)
662 {
663  if (parser.haveSettings) {
664  throw FatalError("Only one setting option allowed");
665  }
666  try {
667  auto& settingsConfig = parser.reactor.getGlobalCommandController().getSettingsConfig();
668  settingsConfig.loadSetting(
669  CurrentDirFileContext(), getArgument(option, cmdLine));
670  parser.haveSettings = true;
671  } catch (FileException& e) {
672  throw FatalError(e.getMessage());
673  } catch (ConfigException& e) {
674  throw FatalError(e.getMessage());
675  }
676 }
677 
679 {
680  return "Load an alternative settings file";
681 }
682 
683 
684 // class NoPBOOption
685 
686 void NoPBOOption::parseOption(const string& /*option*/,
687  array_ref<string>& /*cmdLine*/)
688 {
689  #if COMPONENT_GL
690  cout << "Disabling PBO" << endl;
692  #endif
693 }
694 
696 {
697  return "Disables usage of openGL PBO (for debugging)";
698 }
699 
700 
701 // class TestConfigOption
702 
704  : parser(parser_)
705 {
706 }
707 
708 void TestConfigOption::parseOption(const string& /*option*/,
709  array_ref<string>& /*cmdLine*/)
710 {
711  parser.parseStatus = CommandLineParser::TEST;
712 }
713 
715 {
716  return "Test if the specified config works and exit";
717 }
718 
719 // class BashOption
720 
722  : parser(parser_)
723 {
724 }
725 
726 void BashOption::parseOption(const string& /*option*/,
727  array_ref<string>& cmdLine)
728 {
729  string last = cmdLine.empty() ? "" : cmdLine.front();
730  cmdLine.clear(); // eat all remaining parameters
731 
732  if (last == "-machine") {
733  for (auto& s : Reactor::getHwConfigs("machines")) {
734  cout << s << '\n';
735  }
736  } else if (StringOp::startsWith(last, "-ext")) {
737  for (auto& s : Reactor::getHwConfigs("extensions")) {
738  cout << s << '\n';
739  }
740  } else if (last == "-romtype") {
741  for (auto& s : RomInfo::getAllRomTypes()) {
742  cout << s << '\n';
743  }
744  } else {
745  for (auto& p : parser.options) {
746  cout << p.first << '\n';
747  }
748  }
749  parser.parseStatus = CommandLineParser::EXIT;
750 }
751 
753 {
754  return ""; // don't include this option in --help
755 }
756 
757 } // namespace openmsx
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
T length(const vecN< N, T > &x)
Definition: gl_vec.hh:281
virtual string_ref optionHelp() const
CmpTupleElement< 0, StringOp::caseless > CmpFileTypes
Contains the main loop of openMSX.
Definition: Reactor.hh:62
virtual string_ref optionHelp() const
void pop_front()
Definition: array_ref.hh:91
string_ref::const_iterator end(const string_ref &x)
Definition: string_ref.hh:135
virtual string_ref optionHelp() const
HelpOption(CommandLineParser &parser)
MSXMotherBoard * getMotherBoard() const
const Scripts & getStartupScripts() const
bool isHiddenStartup() const
Need to suppress renderer window on startup?
SettingOption(CommandLineParser &parser)
static std::vector< std::string > getHwConfigs(string_ref type)
Definition: Reactor.cc:359
virtual string_ref optionHelp() const
string getConventionalPath(string_ref path)
Returns the path in conventional path-delimiter.
void splitOnFirst(string_ref str, string_ref chars, string_ref &first, string_ref &last)
Definition: StringOp.cc:311
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
BashOption(CommandLineParser &parser)
virtual string_ref optionHelp() const
void init(const char *programName)
Definition: Interpreter.cc:70
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
void printWarning(string_ref message)
Definition: CliComm.cc:28
const CommandLineParser::Scripts & getScripts() const
TestConfigOption(CommandLineParser &parser)
virtual string_ref optionHelp() const
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
size_type find(string_ref s) const
Definition: string_ref.cc:58
EnumSetting< int > & getMachineSetting()
Definition: Reactor.cc:339
EventDistributor & getEventDistributor()
Definition: Reactor.cc:278
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
virtual std::string getRestoreValue() const
Get the value that will be set after a Tcl 'unset' command.
Definition: Setting.cc:201
static std::vector< string_ref > getAllRomTypes()
Definition: RomInfo.cc:195
CommandLineParser(Reactor &reactor)
GlobalCliComm & getGlobalCliComm()
Definition: Reactor.cc:288
const T & front() const
Definition: array_ref.hh:69
size_type size() const
Definition: string_ref.hh:55
GlobalCommandController & getGlobalCommandController()
Definition: Reactor.cc:283
const char * data() const
Definition: string_ref.hh:68
size_t size_type
Definition: string_ref.hh:21
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
virtual string_ref optionHelp() const
size_type rfind(string_ref s) const
Definition: string_ref.cc:85
std::string getArgument(const std::string &option, array_ref< std::string > &cmdLine) const
Definition: CLIOption.cc:11
#define COMPONENT_LASERDISC
Definition: components.hh:8
MachineOption(CommandLineParser &parser)
void clear()
Definition: array_ref.hh:74
bool startsWith(string_ref total, string_ref part)
Definition: StringOp.cc:241
This class implements a subset of the proposal for std::array_ref (proposed for the next c++ standard...
Definition: array_ref.hh:19
std::unique_ptr< Context > context
Definition: GLContext.cc:9
bool empty() const
Definition: array_ref.hh:62
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
MSXMotherBoard * getMotherBoard() const
Definition: Reactor.cc:402
virtual string_ref optionHelp() const
void registerOption(const char *str, CLIOption &cliOption, ParsePhase phase=PHASE_LAST, unsigned length=2)
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
const std::string & getMessage() const
Definition: MSXException.hh:14
virtual string_ref fileTypeHelp() const
void loadSetting(const FileContext &context, string_ref filename)
static const size_type npos
Definition: string_ref.hh:26
virtual SettingsConfig & getSettingsConfig()
virtual string_ref optionHelp() const
virtual std::string getString() const
Get the current value of this setting in a string format that can be presented to the user...
Definition: Setting.cc:191
void registerFileType(string_ref extensions, CLIFileType &cliFileType)
ControlOption(CommandLineParser &parser)
static bool enabled
Global switch to disable pixel buffers using the "-nopbo" option.
Definition: GLUtil.hh:162
vector< string_ref > split(string_ref str, char chars)
Definition: StringOp.cc:357
GlobalCommandController & getGlobalCommandController() const
VersionOption(CommandLineParser &parser)
virtual void parseFileType(const std::string &filename, array_ref< std::string > &cmdLine)
string_ref getExtension(string_ref path)
Returns the extension portion of a path.
void parse(int argc, char **argv)
std::vector< std::string > Scripts
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
static std::string full()
Definition: Version.cc:7
void printInfo(string_ref message)
Definition: CliComm.cc:23
ParseStatus getParseStatus() const
CliComm & getCliComm()
Definition: Reactor.cc:293
Interpreter & getInterpreter() const
string_ref substr(size_type pos, size_type n=npos) const
Definition: string_ref.cc:52
void switchMachine(const std::string &machine)
Definition: Reactor.cc:464
LessTupleElement< 0 > CmpOptions
string_ref::const_iterator begin(const string_ref &x)
Definition: string_ref.hh:134
std::unique_ptr< T > make_unique()
Definition: memory.hh:27
bool empty() const
Definition: string_ref.hh:56
XRange< T > xrange(T e)
Definition: xrange.hh:98
Interpreter & getInterpreter()
Definition: Reactor.cc:298
void addListener(CliListener *listener)