Merge pull request #14328 from JoshuaVandaele/choices-fix

DolphinTool: Show choices as metavars, and don't lie about defaults
This commit is contained in:
Jordan Woyak
2026-10-03 01:05:15 -05:00
committed by GitHub
3 changed files with 29 additions and 22 deletions
+9 -9
View File
@@ -128,21 +128,21 @@ Usage: convert [options]... [FILE]...
Options:
-h, --help show this help message and exit
-u USER, --user=USER User folder path, required for temporary processing
files.Will be automatically created if this option is
files. Will be automatically created if this option is
not set.
-i FILE, --input=FILE
Path to disc image FILE.
-o FILE, --output=FILE
Path to the destination FILE.
-f FORMAT, --format=FORMAT
Container format to use. Default is RVZ. [iso|gcz|wia|rvz]
-f rvz|iso|gcz|wia, --format=rvz|iso|gcz|wia
Container format to use. Default is RVZ.
-s, --scrub Scrub junk data as part of conversion.
-b BLOCK_SIZE, --block_size=BLOCK_SIZE
Block size for GCZ/WIA/RVZ formats, as an integer.
Suggested value for RVZ: 131072 (128 KiB)
-c COMPRESSION, --compression=COMPRESSION
-c none|zstd|bzip2|lzma|lzma2, --compression=none|zstd|bzip2|lzma|lzma2
Compression method to use when converting to WIA/RVZ.
Suggested value for RVZ: zstd [none|zstd|bzip|lzma|lzma2]
Suggested value for RVZ: zstd
-l COMPRESSION_LEVEL, --compression_level=COMPRESSION_LEVEL
Level of compression for the selected method. Ignored
if 'none'. Suggested value for zstd: 5
@@ -154,13 +154,13 @@ Usage: verify [options]...
Options:
-h, --help show this help message and exit
-u USER, --user=USER User folder path, required for temporary processing
files.Will be automatically created if this option is
files. Will be automatically created if this option is
not set.
-i FILE, --input=FILE
Path to disc image FILE.
-a ALGORITHM, --algorithm=ALGORITHM
Path to input file.
-a crc32|md5|sha1|rchash, --algorithm=crc32|md5|sha1|rchash
Optional. Compute and print the digest using the
selected algorithm, then exit. [crc32|md5|sha1|rchash]
selected algorithm, then exit.
```
```
+13 -10
View File
@@ -3,6 +3,7 @@
#include "DolphinTool/ConvertCommand.h"
#include <array>
#include <cstdlib>
#include <iostream>
#include <limits>
@@ -12,6 +13,7 @@
#include <OptionParser.h>
#include <fmt/ostream.h>
#include <fmt/ranges.h>
#include "Common/CommonTypes.h"
#include "DiscIO/Blob.h"
@@ -56,6 +58,7 @@ static std::optional<DiscIO::BlobType> ParseFormatString(const std::string& form
int ConvertCommand(const std::vector<std::string>& args)
{
using namespace std::literals;
optparse::OptionParser parser;
parser.usage("usage: convert [options]... [FILE]...");
@@ -79,11 +82,14 @@ int ConvertCommand(const std::vector<std::string>& args)
.help("Path to the destination FILE.")
.metavar("FILE");
static constexpr std::array formats{"rvz"sv, "iso"sv, "gcz"sv, "wia"sv};
parser.add_option("-f", "--format")
.type("string")
.action("store")
.help("Container format to use. Default is RVZ. [%choices]")
.choices({"iso", "gcz", "wia", "rvz"});
.help("Container format to use. Default is RVZ.")
.metavar(fmt::format("{}", fmt::join(formats, "|")))
.choices(formats.begin(), formats.end())
.set_default(formats[0]);
parser.add_option("-s", "--scrub")
.action("store_true")
@@ -95,12 +101,14 @@ int ConvertCommand(const std::vector<std::string>& args)
.help("Block size for GCZ/WIA/RVZ formats, as an integer. Suggested value for RVZ: 131072 "
"(128 KiB)");
static constexpr std::array compression_methods{"none"sv, "zstd"sv, "bzip2"sv, "lzma"sv,
"lzma2"sv};
parser.add_option("-c", "--compression")
.type("string")
.action("store")
.help("Compression method to use when converting to WIA/RVZ. Suggested value for RVZ: zstd "
"[%choices]")
.choices({"none", "zstd", "bzip2", "lzma", "lzma2"});
.help("Compression method to use when converting to WIA/RVZ. Suggested value for RVZ: zstd")
.metavar(fmt::format("{}", fmt::join(compression_methods, "|")))
.choices(compression_methods.begin(), compression_methods.end());
parser.add_option("-l", "--compression_level")
.type("int")
@@ -135,11 +143,6 @@ int ConvertCommand(const std::vector<std::string>& args)
// --format
const std::optional<DiscIO::BlobType> format_o = ParseFormatString(options["format"]);
if (!format_o.has_value())
{
fmt::print(std::cerr, "Error: No output format set\n");
return EXIT_FAILURE;
}
const DiscIO::BlobType format = format_o.value();
// Open the blob reader
+7 -3
View File
@@ -3,12 +3,14 @@
#include "DolphinTool/VerifyCommand.h"
#include <array>
#include <cstdlib>
#include <string>
#include <vector>
#include <OptionParser.h>
#include <fmt/ostream.h>
#include <fmt/ranges.h>
#include "Core/AchievementManager.h"
#include "DiscIO/Volume.h"
@@ -74,6 +76,7 @@ static void PrintFullReport(const DiscIO::VolumeVerifier::Result& result)
int VerifyCommand(const std::vector<std::string>& args)
{
using namespace std::literals;
optparse::OptionParser parser;
parser.usage("usage: verify [options]...");
@@ -91,12 +94,13 @@ int VerifyCommand(const std::vector<std::string>& args)
.help("Path to input file.")
.metavar("FILE");
static constexpr std::array algorithms{"crc32"sv, "md5"sv, "sha1"sv, "rchash"sv};
parser.add_option("-a", "--algorithm")
.type("string")
.action("store")
.help("Optional. Compute and print the digest using the selected algorithm, then exit. "
"[%choices]")
.choices({"crc32", "md5", "sha1", "rchash"});
.help("Optional. Compute and print the digest using the selected algorithm, then exit.")
.metavar(fmt::format("{}", fmt::join(algorithms, "|")))
.choices(algorithms.begin(), algorithms.end());
const optparse::Values& options = parser.parse_args(args);