mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-10-11 22:49:50 +00:00
Merge pull request #14328 from JoshuaVandaele/choices-fix
DolphinTool: Show choices as metavars, and don't lie about defaults
This commit is contained in:
@@ -128,21 +128,21 @@ Usage: convert [options]... [FILE]...
|
|||||||
Options:
|
Options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-u USER, --user=USER User folder path, required for temporary processing
|
-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.
|
not set.
|
||||||
-i FILE, --input=FILE
|
-i FILE, --input=FILE
|
||||||
Path to disc image FILE.
|
Path to disc image FILE.
|
||||||
-o FILE, --output=FILE
|
-o FILE, --output=FILE
|
||||||
Path to the destination FILE.
|
Path to the destination FILE.
|
||||||
-f FORMAT, --format=FORMAT
|
-f rvz|iso|gcz|wia, --format=rvz|iso|gcz|wia
|
||||||
Container format to use. Default is RVZ. [iso|gcz|wia|rvz]
|
Container format to use. Default is RVZ.
|
||||||
-s, --scrub Scrub junk data as part of conversion.
|
-s, --scrub Scrub junk data as part of conversion.
|
||||||
-b BLOCK_SIZE, --block_size=BLOCK_SIZE
|
-b BLOCK_SIZE, --block_size=BLOCK_SIZE
|
||||||
Block size for GCZ/WIA/RVZ formats, as an integer.
|
Block size for GCZ/WIA/RVZ formats, as an integer.
|
||||||
Suggested value for RVZ: 131072 (128 KiB)
|
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.
|
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
|
-l COMPRESSION_LEVEL, --compression_level=COMPRESSION_LEVEL
|
||||||
Level of compression for the selected method. Ignored
|
Level of compression for the selected method. Ignored
|
||||||
if 'none'. Suggested value for zstd: 5
|
if 'none'. Suggested value for zstd: 5
|
||||||
@@ -154,13 +154,13 @@ Usage: verify [options]...
|
|||||||
Options:
|
Options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-u USER, --user=USER User folder path, required for temporary processing
|
-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.
|
not set.
|
||||||
-i FILE, --input=FILE
|
-i FILE, --input=FILE
|
||||||
Path to disc image FILE.
|
Path to input file.
|
||||||
-a ALGORITHM, --algorithm=ALGORITHM
|
-a crc32|md5|sha1|rchash, --algorithm=crc32|md5|sha1|rchash
|
||||||
Optional. Compute and print the digest using the
|
Optional. Compute and print the digest using the
|
||||||
selected algorithm, then exit. [crc32|md5|sha1|rchash]
|
selected algorithm, then exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "DolphinTool/ConvertCommand.h"
|
#include "DolphinTool/ConvertCommand.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -12,6 +13,7 @@
|
|||||||
|
|
||||||
#include <OptionParser.h>
|
#include <OptionParser.h>
|
||||||
#include <fmt/ostream.h>
|
#include <fmt/ostream.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "DiscIO/Blob.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)
|
int ConvertCommand(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
|
using namespace std::literals;
|
||||||
optparse::OptionParser parser;
|
optparse::OptionParser parser;
|
||||||
|
|
||||||
parser.usage("usage: convert [options]... [FILE]...");
|
parser.usage("usage: convert [options]... [FILE]...");
|
||||||
@@ -79,11 +82,14 @@ int ConvertCommand(const std::vector<std::string>& args)
|
|||||||
.help("Path to the destination FILE.")
|
.help("Path to the destination FILE.")
|
||||||
.metavar("FILE");
|
.metavar("FILE");
|
||||||
|
|
||||||
|
static constexpr std::array formats{"rvz"sv, "iso"sv, "gcz"sv, "wia"sv};
|
||||||
parser.add_option("-f", "--format")
|
parser.add_option("-f", "--format")
|
||||||
.type("string")
|
.type("string")
|
||||||
.action("store")
|
.action("store")
|
||||||
.help("Container format to use. Default is RVZ. [%choices]")
|
.help("Container format to use. Default is RVZ.")
|
||||||
.choices({"iso", "gcz", "wia", "rvz"});
|
.metavar(fmt::format("{}", fmt::join(formats, "|")))
|
||||||
|
.choices(formats.begin(), formats.end())
|
||||||
|
.set_default(formats[0]);
|
||||||
|
|
||||||
parser.add_option("-s", "--scrub")
|
parser.add_option("-s", "--scrub")
|
||||||
.action("store_true")
|
.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 "
|
.help("Block size for GCZ/WIA/RVZ formats, as an integer. Suggested value for RVZ: 131072 "
|
||||||
"(128 KiB)");
|
"(128 KiB)");
|
||||||
|
|
||||||
|
static constexpr std::array compression_methods{"none"sv, "zstd"sv, "bzip2"sv, "lzma"sv,
|
||||||
|
"lzma2"sv};
|
||||||
parser.add_option("-c", "--compression")
|
parser.add_option("-c", "--compression")
|
||||||
.type("string")
|
.type("string")
|
||||||
.action("store")
|
.action("store")
|
||||||
.help("Compression method to use when converting to WIA/RVZ. Suggested value for RVZ: zstd "
|
.help("Compression method to use when converting to WIA/RVZ. Suggested value for RVZ: zstd")
|
||||||
"[%choices]")
|
.metavar(fmt::format("{}", fmt::join(compression_methods, "|")))
|
||||||
.choices({"none", "zstd", "bzip2", "lzma", "lzma2"});
|
.choices(compression_methods.begin(), compression_methods.end());
|
||||||
|
|
||||||
parser.add_option("-l", "--compression_level")
|
parser.add_option("-l", "--compression_level")
|
||||||
.type("int")
|
.type("int")
|
||||||
@@ -135,11 +143,6 @@ int ConvertCommand(const std::vector<std::string>& args)
|
|||||||
|
|
||||||
// --format
|
// --format
|
||||||
const std::optional<DiscIO::BlobType> format_o = ParseFormatString(options["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();
|
const DiscIO::BlobType format = format_o.value();
|
||||||
|
|
||||||
// Open the blob reader
|
// Open the blob reader
|
||||||
|
|||||||
@@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
#include "DolphinTool/VerifyCommand.h"
|
#include "DolphinTool/VerifyCommand.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <OptionParser.h>
|
#include <OptionParser.h>
|
||||||
#include <fmt/ostream.h>
|
#include <fmt/ostream.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
|
|
||||||
#include "Core/AchievementManager.h"
|
#include "Core/AchievementManager.h"
|
||||||
#include "DiscIO/Volume.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)
|
int VerifyCommand(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
|
using namespace std::literals;
|
||||||
optparse::OptionParser parser;
|
optparse::OptionParser parser;
|
||||||
|
|
||||||
parser.usage("usage: verify [options]...");
|
parser.usage("usage: verify [options]...");
|
||||||
@@ -91,12 +94,13 @@ int VerifyCommand(const std::vector<std::string>& args)
|
|||||||
.help("Path to input file.")
|
.help("Path to input file.")
|
||||||
.metavar("FILE");
|
.metavar("FILE");
|
||||||
|
|
||||||
|
static constexpr std::array algorithms{"crc32"sv, "md5"sv, "sha1"sv, "rchash"sv};
|
||||||
parser.add_option("-a", "--algorithm")
|
parser.add_option("-a", "--algorithm")
|
||||||
.type("string")
|
.type("string")
|
||||||
.action("store")
|
.action("store")
|
||||||
.help("Optional. Compute and print the digest using the selected algorithm, then exit. "
|
.help("Optional. Compute and print the digest using the selected algorithm, then exit.")
|
||||||
"[%choices]")
|
.metavar(fmt::format("{}", fmt::join(algorithms, "|")))
|
||||||
.choices({"crc32", "md5", "sha1", "rchash"});
|
.choices(algorithms.begin(), algorithms.end());
|
||||||
|
|
||||||
const optparse::Values& options = parser.parse_args(args);
|
const optparse::Values& options = parser.parse_args(args);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user