| 1 |
#include "RomInfoTopic.hh" |
| 2 |
|
| 3 |
#include "CommandException.hh" |
| 4 |
#include "RomInfo.hh" |
| 5 |
#include "TclObject.hh" |
| 6 |
|
| 7 |
namespace openmsx { |
| 8 |
|
| 9 |
RomInfoTopic::RomInfoTopic(InfoCommand& openMSXInfoCommand) |
| 10 |
: InfoTopic(openMSXInfoCommand, "romtype") |
| 11 |
{ |
| 12 |
} |
| 13 |
|
| 14 |
void RomInfoTopic::execute(std::span<const TclObject> tokens, TclObject& result) const |
| 15 |
{ |
| 16 |
switch (tokens.size()) { |
| 17 |
case 2: { |
| 18 |
result.addListElements(RomInfo::getAllRomTypes()); |
| 19 |
break; |
| 20 |
} |
| 21 |
case 3: { |
| 22 |
RomType type = RomInfo::nameToRomType(tokens[2].getString()); |
| 23 |
if (type == RomType::UNKNOWN) { |
| 24 |
throw CommandException("Unknown rom type"); |
| 25 |
} |
| 26 |
result.addDictKeyValues("description", RomInfo::getDescription(type), |
| 27 |
"blocksize", int(RomInfo::getBlockSize(type))); |
| 28 |
break; |
| 29 |
} |
| 30 |
default: |
| 31 |
throw CommandException("Too many parameters"); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
std::string RomInfoTopic::help(std::span<const TclObject> ) const |
| 36 |
{ |
| 37 |
return "Shows a list of supported rom types. " |
| 38 |
"Or show info on a specific rom type."; |
| 39 |
} |
| 40 |
|
| 41 |
void RomInfoTopic::tabCompletion(std::vector<std::string>& tokens) const |
| 42 |
{ |
| 43 |
if (tokens.size() == 3) { |
| 44 |
completeString(tokens, RomInfo::getAllRomTypes(), false); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
} |