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(options.begin(), options.end(), CmpOptions());
193  sort(fileTypes.begin(), fileTypes.end(), 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(options.begin(), options.end(), arg,
218  CmpOptions());
219  if ((it != options.end()) && (it->first == arg)) {
220  // parse option
221  if (it->second.phase <= phase) {
222  try {
223  it->second.option->parseOption(arg, cmdLine);
224  return true;
225  } catch (MSXException& e) {
226  throw FatalError(e.getMessage());
227  }
228  }
229  }
230  return false; // unknown
231 }
232 
233 bool CommandLineParser::parseFileName(const string& arg, array_ref<string>& cmdLine)
234 {
235  // First try the fileName as we get it from the commandline. This may
236  // be more interesting than the original fileName of a (g)zipped file:
237  // in case of an OMR file for instance, we want to select on the
238  // original extension, and not on the extension inside the gzipped
239  // file.
240  bool processed = parseFileNameInner(arg, arg, cmdLine);
241  if (!processed) {
242  try {
243  File file(UserFileContext().resolve(arg));
244  string originalName = file.getOriginalName();
245  processed = parseFileNameInner(originalName, arg, cmdLine);
246  } catch (FileException&) {
247  // ignore
248  }
249  }
250  return processed;
251 }
252 
253 bool CommandLineParser::parseFileNameInner(const string& name, const string& originalPath, array_ref<string>& cmdLine)
254 {
255  string_ref extension = FileOperations::getExtension(name);
256  if (extension.empty()) {
257  return false; // no extension
258  }
259 
260  auto it = lower_bound(fileTypes.begin(), fileTypes.end(), extension,
261  CmpFileTypes());
262  StringOp::casecmp cmp;
263  if ((it == fileTypes.end()) || !cmp(it->first, extension)) {
264  return false; // unknown extension
265  }
266 
267  try {
268  // parse filetype
269  it->second->parseFileType(originalPath, cmdLine);
270  return true; // file processed
271  } catch (MSXException& e) {
272  throw FatalError(e.getMessage());
273  }
274 }
275 
276 void CommandLineParser::parse(int argc, char** argv)
277 {
278  parseStatus = RUN;
279 
280  vector<string> cmdLineBuf;
281  for (auto i : xrange(1, argc)) {
282  cmdLineBuf.push_back(FileOperations::getConventionalPath(argv[i]));
283  }
284  array_ref<string> cmdLine(cmdLineBuf);
285  vector<string> backupCmdLine;
286 
287  for (ParsePhase phase = PHASE_BEFORE_INIT;
288  (phase <= PHASE_LAST) && (parseStatus != EXIT);
289  phase = static_cast<ParsePhase>(phase + 1)) {
290  switch (phase) {
291  case PHASE_INIT:
292  reactor.init();
293  reactor.getGlobalCommandController().getInterpreter().init(argv[0]);
294  break;
295  case PHASE_LOAD_SETTINGS:
296  // after -control and -setting has been parsed
297  if (parseStatus != CONTROL) {
298  // if there already is a XML-StdioConnection, we
299  // can't also show plain messages on stdout
300  auto& cliComm = reactor.getGlobalCliComm();
301  cliComm.addListener(new StdioMessages());
302  }
303  if (!haveSettings) {
304  auto& settingsConfig =
306  // Load default settings file in case the user
307  // didn't specify one.
308  SystemFileContext context;
309  string filename = "settings.xml";
310  try {
311  settingsConfig.loadSetting(context, filename);
312  } catch (XMLException& e) {
313  reactor.getCliComm().printWarning(
314  "Loading of settings failed: " +
315  e.getMessage() + "\n"
316  "Reverting to default settings.");
317  } catch (FileException&) {
318  // settings.xml not found
319  } catch (ConfigException& e) {
320  throw FatalError("Error in default settings: "
321  + e.getMessage());
322  }
323  // Consider an attempt to load the settings good enough.
324  haveSettings = true;
325  // Even if parsing failed, use this file for saving,
326  // this forces overwriting a non-setting file.
327  settingsConfig.setSaveFilename(context, filename);
328  }
329  break;
330  case PHASE_LOAD_MACHINE: {
331  if (!haveConfig) {
332  // load default config file in case the user didn't specify one
333  const auto& machine =
334  reactor.getMachineSetting().getString();
335  try {
336  reactor.switchMachine(machine);
337  } catch (MSXException& e) {
338  reactor.getCliComm().printInfo(
339  "Failed to initialize default machine: " + e.getMessage());
340  // Default machine is broken; fall back to C-BIOS config.
341  const auto& fallbackMachine =
343  reactor.getCliComm().printInfo("Using fallback machine: " + fallbackMachine);
344  try {
345  reactor.switchMachine(fallbackMachine);
346  } catch (MSXException& e2) {
347  // Fallback machine failed as well; we're out of options.
348  throw FatalError(e2.getMessage());
349  }
350  }
351  haveConfig = true;
352  }
353  break;
354  }
355  default:
356  // iterate over all arguments
357  while (!cmdLine.empty()) {
358  string arg = std::move(cmdLine.front());
359  cmdLine.pop_front();
360  // first try options
361  if (!parseOption(arg, cmdLine, phase)) {
362  // next try the registered filetypes (xml)
363  if ((phase != PHASE_LAST) ||
364  !parseFileName(arg, cmdLine)) {
365  // no option or known file
366  backupCmdLine.push_back(arg);
367  auto it = lower_bound(options.begin(), options.end(), arg, CmpOptions());
368  if ((it != options.end()) && (it->first == arg)) {
369  for (unsigned i = 0; i < it->second.length - 1; ++i) {
370  if (!cmdLine.empty()) {
371  backupCmdLine.push_back(std::move(cmdLine.front()));
372  cmdLine.pop_front();
373  }
374  }
375  }
376  }
377  }
378  }
379  std::swap(backupCmdLine, cmdLineBuf);
380  backupCmdLine.clear();
381  cmdLine = cmdLineBuf;
382  break;
383  }
384  }
385  if (!cmdLine.empty() && (parseStatus != EXIT)) {
386  throw FatalError(
387  "Error parsing command line: " + cmdLine.front() + "\n" +
388  "Use \"openmsx -h\" to see a list of available options" );
389  }
390 
391  hiddenStartup = (parseStatus == CONTROL || parseStatus == TEST );
392 }
393 
395 {
396  return hiddenStartup;
397 }
398 
400 {
401  assert(parseStatus != UNPARSED);
402  return parseStatus;
403 }
404 
406 {
407  return scriptOption->getScripts();
408 }
409 
411 {
412  return reactor.getMotherBoard();
413 }
414 
416 {
417  return reactor.getGlobalCommandController();
418 }
419 
420 
421 // Control option
422 
424  : parser(parser_)
425 {
426 }
427 
428 void ControlOption::parseOption(const string& option, array_ref<string>& cmdLine)
429 {
430  const auto& fullType = getArgument(option, cmdLine);
431  string_ref type, arguments;
432  StringOp::splitOnFirst(fullType, ':', type, arguments);
433 
434  auto& controller = parser.getGlobalCommandController();
435  auto& distributor = parser.reactor.getEventDistributor();
436  auto& cliComm = parser.reactor.getGlobalCliComm();
437  std::unique_ptr<CliListener> connection;
438  if (type == "stdio") {
439  connection = make_unique<StdioConnection>(
440  controller, distributor);
441 #ifdef _WIN32
442  } else if (type == "pipe") {
443  OSVERSIONINFO info;
444  info.dwOSVersionInfoSize = sizeof(info);
445  GetVersionEx(&info);
446  if (info.dwPlatformId == VER_PLATFORM_WIN32_NT) {
447  connection = make_unique<PipeConnection>(
448  controller, distributor, arguments);
449  } else {
450  throw FatalError("Pipes are not supported on this "
451  "version of Windows");
452  }
453 #endif
454  } else {
455  throw FatalError("Unknown control type: '" + type + '\'');
456  }
457  cliComm.addListener(connection.release());
458 
459  parser.parseStatus = CommandLineParser::CONTROL;
460 }
461 
463 {
464  return "Enable external control of openMSX process";
465 }
466 
467 
468 // Script option
469 
471 {
472  return scripts;
473 }
474 
475 void ScriptOption::parseOption(const string& option, array_ref<string>& cmdLine)
476 {
477  parseFileType(getArgument(option, cmdLine), cmdLine);
478 }
479 
481 {
482  return "Run extra startup script";
483 }
484 
485 void ScriptOption::parseFileType(const string& filename,
486  array_ref<std::string>& /*cmdLine*/)
487 {
488  scripts.push_back(filename);
489 }
490 
492 {
493  return "Extra Tcl script to run at startup";
494 }
495 
496 // Help option
497 
498 static string formatSet(const vector<string_ref>& inputSet, string::size_type columns)
499 {
500  StringOp::Builder outString;
501  string::size_type totalLength = 0; // ignore the starting spaces for now
502  for (auto& temp : inputSet) {
503  if (totalLength == 0) {
504  // first element ?
505  outString << " " << temp;
506  totalLength = temp.size();
507  } else {
508  outString << ", ";
509  if ((totalLength + temp.size()) > columns) {
510  outString << "\n " << temp;
511  totalLength = temp.size();
512  } else {
513  outString << temp;
514  totalLength += 2 + temp.size();
515  }
516  }
517  }
518  if (totalLength < columns) {
519  outString << string(columns - totalLength, ' ');
520  }
521  return outString;
522 }
523 
524 static string formatHelptext(string_ref helpText,
525  unsigned maxLength, unsigned indent)
526 {
527  string outText;
528  string_ref::size_type index = 0;
529  while (helpText.substr(index).size() > maxLength) {
530  auto pos = helpText.substr(index, maxLength).rfind(' ');
531  if (pos == string_ref::npos) {
532  pos = helpText.substr(maxLength).find(' ');
533  if (pos == string_ref::npos) {
534  pos = helpText.substr(index).size();
535  }
536  }
537  outText += helpText.substr(index, index + pos) + '\n' +
538  string(indent, ' ');
539  index = pos + 1;
540  }
541  string_ref t = helpText.substr(index);
542  outText.append(t.data(), t.size());
543  return outText;
544 }
545 
546 static void printItemMap(const StringMap<vector<string_ref>>& itemMap)
547 {
548  vector<string> printSet;
549  for (auto& p : itemMap) {
550  printSet.push_back(formatSet(p.second, 15) + ' ' +
551  formatHelptext(p.first(), 50, 20));
552  }
553  sort(printSet.begin(), printSet.end());
554  for (auto& s : printSet) {
555  cout << s << endl;
556  }
557 }
558 
560  : parser(parser_)
561 {
562 }
563 
564 void HelpOption::parseOption(const string& /*option*/,
565  array_ref<string>& /*cmdLine*/)
566 {
567  const auto& fullVersion = Version::full();
568  cout << fullVersion << endl;
569  cout << string(fullVersion.size(), '=') << endl;
570  cout << endl;
571  cout << "usage: openmsx [arguments]" << endl;
572  cout << " an argument is either an option or a filename" << endl;
573  cout << endl;
574  cout << " this is the list of supported options:" << endl;
575 
576  StringMap<vector<string_ref>> optionMap;
577  for (auto& p : parser.options) {
578  const auto& helpText = p.second.option->optionHelp();
579  if (!helpText.empty()) {
580  optionMap[helpText].push_back(p.first);
581  }
582  }
583  printItemMap(optionMap);
584 
585  cout << endl;
586  cout << " this is the list of supported file types:" << endl;
587 
589  for (auto& p : parser.fileTypes) {
590  extMap[p.second->fileTypeHelp()].push_back(p.first);
591  }
592  printItemMap(extMap);
593 
594  parser.parseStatus = CommandLineParser::EXIT;
595 }
596 
598 {
599  return "Shows this text";
600 }
601 
602 
603 // class VersionOption
604 
606  : parser(parser_)
607 {
608 }
609 
610 void VersionOption::parseOption(const string& /*option*/,
611  array_ref<string>& /*cmdLine*/)
612 {
613  cout << Version::full() << endl;
614  cout << "flavour: " << BUILD_FLAVOUR << endl;
615  cout << "components: " << BUILD_COMPONENTS << endl;
616  parser.parseStatus = CommandLineParser::EXIT;
617 }
618 
620 {
621  return "Prints openMSX version and exits";
622 }
623 
624 
625 // Machine option
626 
628  : parser(parser_)
629 {
630 }
631 
632 void MachineOption::parseOption(const string& option, array_ref<string>& cmdLine)
633 {
634  if (parser.haveConfig) {
635  throw FatalError("Only one machine option allowed");
636  }
637  try {
638  parser.reactor.switchMachine(getArgument(option, cmdLine));
639  } catch (MSXException& e) {
640  throw FatalError(e.getMessage());
641  }
642  parser.haveConfig = true;
643 }
645 {
646  return "Use machine specified in argument";
647 }
648 
649 
650 // Setting Option
651 
653  : parser(parser_)
654 {
655 }
656 
657 void SettingOption::parseOption(const string& option, array_ref<string>& cmdLine)
658 {
659  if (parser.haveSettings) {
660  throw FatalError("Only one setting option allowed");
661  }
662  try {
663  auto& settingsConfig = parser.reactor.getGlobalCommandController().getSettingsConfig();
664  settingsConfig.loadSetting(
665  CurrentDirFileContext(), getArgument(option, cmdLine));
666  parser.haveSettings = true;
667  } catch (FileException& e) {
668  throw FatalError(e.getMessage());
669  } catch (ConfigException& e) {
670  throw FatalError(e.getMessage());
671  }
672 }
673 
675 {
676  return "Load an alternative settings file";
677 }
678 
679 
680 // class NoPBOOption
681 
682 void NoPBOOption::parseOption(const string& /*option*/,
683  array_ref<string>& /*cmdLine*/)
684 {
685  #if COMPONENT_GL
686  cout << "Disabling PBO" << endl;
687  PixelBuffers::enabled = false;
688  #endif
689 }
690 
692 {
693  return "Disables usage of openGL PBO (for debugging)";
694 }
695 
696 
697 // class TestConfigOption
698 
700  : parser(parser_)
701 {
702 }
703 
704 void TestConfigOption::parseOption(const string& /*option*/,
705  array_ref<string>& /*cmdLine*/)
706 {
707  parser.parseStatus = CommandLineParser::TEST;
708 }
709 
711 {
712  return "Test if the specified config works and exit";
713 }
714 
715 // class BashOption
716 
718  : parser(parser_)
719 {
720 }
721 
722 void BashOption::parseOption(const string& /*option*/,
723  array_ref<string>& cmdLine)
724 {
725  string last = cmdLine.empty() ? "" : cmdLine.front();
726  cmdLine.clear(); // eat all remaining parameters
727 
728  if (last == "-machine") {
729  for (auto& s : Reactor::getHwConfigs("machines")) {
730  cout << s << '\n';
731  }
732  } else if (StringOp::startsWith(last, "-ext")) {
733  for (auto& s : Reactor::getHwConfigs("extensions")) {
734  cout << s << '\n';
735  }
736  } else if (last == "-romtype") {
737  for (auto& s : RomInfo::getAllRomTypes()) {
738  cout << s << '\n';
739  }
740  } else {
741  for (auto& p : parser.options) {
742  cout << p.first << '\n';
743  }
744  }
745  parser.parseStatus = CommandLineParser::EXIT;
746 }
747 
749 {
750  return ""; // don't include this option in --help
751 }
752 
753 } // namespace openmsx
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
virtual string_ref optionHelp() const
CmpTupleElement< 0, StringOp::caseless > CmpFileTypes
Contains the main loop of openMSX.
Definition: Reactor.hh:61
virtual string_ref optionHelp() const
void pop_front()
Definition: array_ref.hh:89
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:354
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:300
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:66
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:334
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:194
CommandLineParser(Reactor &reactor)
GlobalCliComm & getGlobalCliComm()
Definition: Reactor.cc:288
const T & front() const
Definition: array_ref.hh:67
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:72
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
bool empty() const
Definition: array_ref.hh:60
virtual void parseOption(const string &option, array_ref< string > &cmdLine)
MSXMotherBoard * getMotherBoard() const
Definition: Reactor.cc:397
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
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)
vector< string_ref > split(string_ref str, char chars)
Definition: StringOp.cc:346
GlobalCommandController & getGlobalCommandController() const
static bool enabled
Global switch to disable pixel buffers using the "-nopbo" option.
Definition: GLUtil.hh:187
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
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:459
LessTupleElement< 0 > CmpOptions
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:92
void loadSetting(const FileContext &context, const std::string &filename)
void addListener(CliListener *listener)