Implement CLI list subcommand.

This commit is contained in:
Maxim Poliakovski 2020-10-13 04:24:54 +02:00
parent 27f5d981da
commit 90b2eb712a
3 changed files with 43 additions and 3 deletions

View File

@ -76,8 +76,15 @@ static const PropMap GossamerSettings = {
new IntProperty( 2, vector<uint32_t>({2, 4, 6}))},
};
static const map<string, tuple<PropMap, function<int(void)>>> machines = {
{"pmg3", {GossamerSettings, create_gossamer}},
static const map<string, string> PropHelp = {
{"rambank1_size", "specifies RAM bank 1 size in MB"},
{"rambank2_size", "specifies RAM bank 2 size in MB"},
{"rambank3_size", "specifies RAM bank 3 size in MB"},
{"gfxmem_size", "specifies video memory size in MB"},
};
static const map<string, tuple<PropMap, function<int(void)>, string>> machines = {
{"pmg3", {GossamerSettings, create_gossamer, "PowerMacintosh G3 (Beige)"}},
};
string machine_name_from_rom(string& rom_filepath) {
@ -169,6 +176,30 @@ void set_machine_settings(map<string, string> &settings) {
}
}
void list_machines() {
cout << endl << "Supported machines:" << endl << endl;
for (auto& mach : machines) {
cout << mach.first << "\t\t" << get<2>(mach.second) << endl;
}
cout << endl;
}
void list_properties() {
cout << endl;
for (auto& mach : machines) {
cout << get<2>(mach.second) << " properties:" << endl << endl;
for (auto& p : get<0>(mach.second)) {
cout << p.first << "\t\t" << PropHelp.at(p.first) << endl << endl;
}
}
cout << endl;
}
/* Read ROM file content and transfer it to the dedicated ROM region */
void load_rom(std::ifstream& rom_file, uint32_t file_size) {
unsigned char* sysrom_mem = new unsigned char[file_size];

View File

@ -38,6 +38,8 @@ std::string machine_name_from_rom(std::string& rom_filepath);
int get_machine_settings(string& id, map<string, string> &settings);
void set_machine_settings(map<string, string> &settings);
int create_machine_for_id(string& id, string& rom_filepath);
void list_machines(void);
void list_properties(void);
/* Machine-specific factory functions. */
int create_gossamer(void);

View File

@ -101,7 +101,14 @@ int main(int argc, char** argv) {
CLI11_PARSE(app, argc, argv);
if (*list_cmd) {
std::cout << "Got: " << sub_arg << std::endl;
if (sub_arg == "machines") {
list_machines();
} else if (sub_arg == "properties") {
list_properties();
} else {
cout << "Unknown list subcommand " << sub_arg << endl;
}
return 0;
}
if (debugger_enabled) {