mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-18 17:00:30 -04:00
refactor: prefer fmt::join + ranges over folly::gen
This commit is contained in:
parent
960346c019
commit
3ce99d6a43
@ -30,9 +30,11 @@
|
|||||||
|
|
||||||
#include <fmt/chrono.h>
|
#include <fmt/chrono.h>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#if FMT_VERSION >= 110000
|
||||||
|
#include <fmt/ranges.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <folly/String.h>
|
#include <folly/String.h>
|
||||||
#include <folly/gen/String.h>
|
|
||||||
#include <folly/portability/Unistd.h>
|
#include <folly/portability/Unistd.h>
|
||||||
#include <folly/system/HardwareConcurrency.h>
|
#include <folly/system/HardwareConcurrency.h>
|
||||||
|
|
||||||
@ -160,13 +162,11 @@ void do_checksum(logger& lgr, filesystem_v2& fs, iolayer const& iol,
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
|
int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||||
using namespace folly::gen;
|
|
||||||
|
|
||||||
const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u);
|
const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u);
|
||||||
|
|
||||||
auto algo_list = checksum::available_algorithms();
|
auto algo_list = checksum::available_algorithms();
|
||||||
auto checksum_desc = "print checksums for all files (" +
|
auto checksum_desc = fmt::format("print checksums for all files ({})",
|
||||||
(from(algo_list) | unsplit(", ")) + ")";
|
fmt::join(algo_list, ", "));
|
||||||
|
|
||||||
sys_string input, export_metadata;
|
sys_string input, export_metadata;
|
||||||
std::string image_offset, checksum_algo;
|
std::string image_offset, checksum_algo;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <ranges>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -50,11 +51,13 @@
|
|||||||
#include <folly/FileUtil.h>
|
#include <folly/FileUtil.h>
|
||||||
#include <folly/String.h>
|
#include <folly/String.h>
|
||||||
#include <folly/container/Enumerate.h>
|
#include <folly/container/Enumerate.h>
|
||||||
#include <folly/gen/String.h>
|
|
||||||
#include <folly/portability/SysStat.h>
|
#include <folly/portability/SysStat.h>
|
||||||
#include <folly/system/HardwareConcurrency.h>
|
#include <folly/system/HardwareConcurrency.h>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#if FMT_VERSION >= 110000
|
||||||
|
#include <fmt/ranges.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <dwarfs/block_compressor.h>
|
#include <dwarfs/block_compressor.h>
|
||||||
#include <dwarfs/block_compressor_parser.h>
|
#include <dwarfs/block_compressor_parser.h>
|
||||||
@ -369,7 +372,6 @@ void validate(boost::any& v, std::vector<std::string> const& values,
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||||
using namespace folly::gen;
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u);
|
const size_t num_cpu = std::max(folly::hardware_concurrency(), 1u);
|
||||||
@ -407,27 +409,27 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
|||||||
|
|
||||||
auto order_desc = "inode fragments order (" + order_parser.choices() + ")";
|
auto order_desc = "inode fragments order (" + order_parser.choices() + ")";
|
||||||
|
|
||||||
auto progress_desc = "progress mode (" +
|
auto progress_desc = fmt::format(
|
||||||
(from(progress_modes) | get<0>() | unsplit(", ")) + ")";
|
"progress mode ({})", fmt::join(progress_modes | std::views::keys, ", "));
|
||||||
|
|
||||||
auto debug_filter_desc =
|
auto debug_filter_desc =
|
||||||
"show effect of filter rules without producing an image (" +
|
fmt::format("show effect of filter rules without producing an image ({})",
|
||||||
(from(debug_filter_modes) | get<0>() | unsplit(", ")) + ")";
|
fmt::join(debug_filter_modes | std::views::keys, ", "));
|
||||||
|
|
||||||
auto resolution_desc = "time resolution in seconds or (" +
|
auto resolution_desc =
|
||||||
(from(time_resolutions) | get<0>() | unsplit(", ")) +
|
fmt::format("time resolution in seconds or ({})",
|
||||||
")";
|
fmt::join(time_resolutions | std::views::keys, ", "));
|
||||||
|
|
||||||
auto hash_list = checksum::available_algorithms();
|
auto hash_list = checksum::available_algorithms();
|
||||||
|
|
||||||
auto file_hash_desc = "choice of file hashing function (none, " +
|
auto file_hash_desc = fmt::format(
|
||||||
(from(hash_list) | unsplit(", ")) + ")";
|
"choice of file hashing function (none, {})", fmt::join(hash_list, ", "));
|
||||||
|
|
||||||
auto& catreg = categorizer_registry::instance();
|
auto& catreg = categorizer_registry::instance();
|
||||||
|
|
||||||
auto categorize_desc = "enable categorizers in the given order (" +
|
auto categorize_desc =
|
||||||
(from(catreg.categorizer_names()) | unsplit(", ")) +
|
fmt::format("enable categorizers in the given order ({})",
|
||||||
")";
|
fmt::join(catreg.categorizer_names(), ", "));
|
||||||
|
|
||||||
auto lvl_def_val = [](auto opt) {
|
auto lvl_def_val = [](auto opt) {
|
||||||
return fmt::format("arg (={})", levels[default_level].*opt);
|
return fmt::format("arg (={})", levels[default_level].*opt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user