Add some temporary options for choosing what to print.
I'm planning to let users pass in some format string in the future instead, but for now this is what I've got.
This commit is contained in:
parent
e40d092b7d
commit
f1157429ba
3 changed files with 48 additions and 13 deletions
|
@ -25,6 +25,13 @@ int main(int argc, char* argv[]) {
|
|||
("h,help", "Show this help and quit")
|
||||
("version", "Print version info")
|
||||
("i,input", "Path to the input memory card file", cxxopts::value<string>()->default_value(""))
|
||||
("blocknum", "Print the block number for each savegame")
|
||||
("usedblocks", "Print how many blocks are used for each savegame if more than 1")
|
||||
("pocketstation", "Print a 'P' to mark when a savegame contains PocketStation data")
|
||||
("countrycode", "Print the country code of each savegame")
|
||||
("productcode", "Print the product code of the game")
|
||||
("identifier", "Print the unique savegame identifier")
|
||||
("toccheck", "Print the TOC checksum for each savegame")
|
||||
;
|
||||
auto command = options.parse(argc, argv);
|
||||
|
||||
|
@ -46,6 +53,17 @@ int main(int argc, char* argv[]) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
print_blocks(mc_path);
|
||||
{
|
||||
PrintOptions opts;
|
||||
opts.title = true;
|
||||
opts.block_num = command.count("blocknum") > 0;
|
||||
opts.used_blocks = command.count("usedblocks") > 0;
|
||||
opts.has_pocket_station_content = command.count("pocketstation") > 0;
|
||||
opts.country_code = command.count("countrycode") > 0;
|
||||
opts.product_code = command.count("productcode") > 0;
|
||||
opts.savegame_identifier = command.count("identifier") > 0;
|
||||
opts.toc_checksum = command.count("toccheck") > 0;
|
||||
print_blocks(mc_path, opts);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
void print_blocks (const std::string& mc_path) {
|
||||
void print_blocks (const std::string& mc_path, const PrintOptions& opts) {
|
||||
using mc::psx::MemoryCard;
|
||||
using mc::psx::make_memory_card;
|
||||
|
||||
|
@ -19,16 +19,22 @@ void print_blocks (const std::string& mc_path) {
|
|||
|
||||
for (const auto& blk : mc) {
|
||||
if (blk.has_magic()) {
|
||||
std::cout << "Block " << std::setfill(' ') << std::setw(2) << blk.index()
|
||||
<< ": \"" << blk.title() << '"';
|
||||
if (blk.block_count() > 1) {
|
||||
std::cout << " (x" << blk.block_count() << ')';
|
||||
}
|
||||
if (blk.has_pocket_station_content())
|
||||
if (opts.block_num)
|
||||
std::cout << "Block " << std::setfill(' ') << std::setw(2) << blk.index() << ": ";
|
||||
if (opts.title)
|
||||
std::cout << '"' << blk.title() << "\" ";
|
||||
if (opts.used_blocks and blk.block_count() > 1)
|
||||
std::cout << "(x" << blk.block_count() << ") ";
|
||||
if (opts.has_pocket_station_content and blk.has_pocket_station_content())
|
||||
std::cout << "P ";
|
||||
std::cout << " [" << to_char(blk.country_code()) << ']';
|
||||
std::cout << ' ' << blk.product_code();
|
||||
std::cout << " '" << blk.identifier() << '\'';
|
||||
if (opts.country_code)
|
||||
std::cout << '[' << to_char(blk.country_code()) << "] ";
|
||||
if (opts.product_code)
|
||||
std::cout << blk.product_code() << ' ';
|
||||
if (opts.savegame_identifier)
|
||||
std::cout << '\'' << blk.identifier() << "' ";
|
||||
if (opts.toc_checksum)
|
||||
std::cout << "0x" << std::setfill('0') << std::setw(2) << std::hex << static_cast<int>(blk.toc_checksum()) << std::dec << ' ';
|
||||
std::cout << '\n';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,4 +2,15 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
void print_blocks (const std::string& mc_path);
|
||||
struct PrintOptions {
|
||||
bool title;
|
||||
bool block_num;
|
||||
bool used_blocks;
|
||||
bool has_pocket_station_content;
|
||||
bool country_code;
|
||||
bool product_code;
|
||||
bool savegame_identifier;
|
||||
bool toc_checksum;
|
||||
};
|
||||
|
||||
void print_blocks (const std::string& mc_path, const PrintOptions& opts);
|
||||
|
|
Loading…
Add table
Reference in a new issue