CDImageCLI.cc 922 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "CDImageCLI.hh"
  2. #include "CommandLineParser.hh"
  3. #include "GlobalCommandController.hh"
  4. #include "TclObject.hh"
  5. #include "MSXException.hh"
  6. using std::string;
  7. namespace openmsx {
  8. CDImageCLI::CDImageCLI(CommandLineParser& parser_)
  9. : parser(parser_)
  10. {
  11. parser.registerOption("-cda", *this);
  12. // TODO: offer more options in case you want to specify 2 hard disk images?
  13. }
  14. void CDImageCLI::parseOption(const string& option, span<string>& cmdLine)
  15. {
  16. auto cd = std::string_view(option).substr(1); // cda
  17. string filename = getArgument(option, cmdLine);
  18. if (!parser.getGlobalCommandController().hasCommand(cd)) { // TODO WIP
  19. throw MSXException("No CDROM named '", cd, "'.");
  20. }
  21. TclObject command = makeTclList(cd, filename);
  22. command.executeCommand(parser.getInterpreter());
  23. }
  24. std::string_view CDImageCLI::optionHelp() const
  25. {
  26. return "Use iso image in argument for the CDROM extension";
  27. }
  28. } // namespace openmsx