| 1 |
#include "CassettePlayerCLI.hh" |
| 2 |
|
| 3 |
#include "CommandLineParser.hh" |
| 4 |
#include "Interpreter.hh" |
| 5 |
#include "MSXException.hh" |
| 6 |
#include "TclObject.hh" |
| 7 |
|
| 8 |
namespace openmsx { |
| 9 |
|
| 10 |
std::span<const std::string_view> CassettePlayerCLI::getExtensions() |
| 11 |
{ |
| 12 |
static constexpr auto extensions = std::to_array<std::string_view>({ |
| 13 |
"cas", "wav", "tsx" |
| 14 |
}); |
| 15 |
return extensions; |
| 16 |
} |
| 17 |
|
| 18 |
CassettePlayerCLI::CassettePlayerCLI(CommandLineParser& parser_) |
| 19 |
: parser(parser_) |
| 20 |
{ |
| 21 |
parser.registerOption("-cassetteplayer", *this); |
| 22 |
parser.registerFileType(getExtensions(), *this); |
| 23 |
} |
| 24 |
|
| 25 |
void CassettePlayerCLI::parseOption(const std::string& option, |
| 26 |
std::span<std::string>& cmdLine) |
| 27 |
{ |
| 28 |
parseFileType(getArgument(option, cmdLine), cmdLine); |
| 29 |
} |
| 30 |
|
| 31 |
std::string_view CassettePlayerCLI::optionHelp() const |
| 32 |
{ |
| 33 |
return "Put cassette image specified in argument in " |
| 34 |
"virtual cassetteplayer"; |
| 35 |
} |
| 36 |
|
| 37 |
void CassettePlayerCLI::parseFileType(const std::string& filename, |
| 38 |
std::span<std::string>& ) |
| 39 |
{ |
| 40 |
if (!parser.getInterpreter().hasCommand("cassetteplayer")) { |
| 41 |
throw MSXException("No cassette player present."); |
| 42 |
} |
| 43 |
TclObject command = makeTclList("cassetteplayer", filename); |
| 44 |
command.executeCommand(parser.getInterpreter()); |
| 45 |
} |
| 46 |
|
| 47 |
std::string_view CassettePlayerCLI::fileTypeHelp() const |
| 48 |
{ |
| 49 |
return "Cassette image, raw recording, fMSX CAS image or TSX file"; |
| 50 |
} |
| 51 |
|
| 52 |
std::string_view CassettePlayerCLI::fileTypeCategoryName() const |
| 53 |
{ |
| 54 |
return "cassette"; |
| 55 |
} |
| 56 |
|
| 57 |
} |