10#include "fruit/fruit.h"
33 :
Command{parent_app, kCommandName, kCommandDesc, kCommandGroup}
36 cmd.add_option(
"<tileset-name>", tileset_name_,
"Name of the tileset to dump config for")->required();
46 const bool no_color = !isatty(STDERR_FILENO);
47 fruit::Injector injector{di::get_formatter_component, no_color};
51 auto stderr_diag = std::make_unique<StderrStyledUserDiagnostics>(text_formatter);
53 std::filesystem::path project_root = project_root_opt_.
project_root();
54 std::filesystem::path fieldmap_header_root_relative{
"include/fieldmap.h"};
57 std::vector<std::unique_ptr<ConfigProvider>> providers{};
58 providers.push_back(std::make_unique<CliOptionProvider>(cli_storage_));
59 auto yaml_provider = std::make_unique<YamlFileProvider>(text_formatter, stderr_diag.get(), project_root);
60 auto *yaml_provider_ptr = yaml_provider.get();
61 providers.push_back(std::move(yaml_provider));
63 std::make_unique<HeaderDefineProvider>(project_root, fieldmap_header_root_relative, text_formatter));
64 providers.push_back(std::make_unique<MetatilesHeaderProvider>(project_root, text_formatter));
65 providers.push_back(std::make_unique<DefaultProvider>());
69 if (yaml_provider_ptr->preload_and_validate(ConfigScopeType::tileset, tileset_name_)) {
71 "Configuration validation failed for tileset '{}'.",
FormatParam{tileset_name_, Style::bold}}};
72 stderr_diag->fatal(validation_err);
73 throw CLI::RuntimeError{1};
76 config.dump_config(std::cout, ConfigScopeType::tileset, tileset_name_);
80 static constexpr auto kCommandName =
"dump-tileset-config";
81 static constexpr auto kCommandDesc =
"Dump the full configuration provenance chain for a tileset.";
82 static constexpr auto kCommandGroup =
"UTILITIES";
83 std::string tileset_name_;
Command is an abstract class that provides basic command functionality for the Porytiles CLI driver.
CLI::App & get_app() const
DumpTilesetConfigCommand(CLI::App &parent_app)
std::filesystem::path project_root() const
void RegisterOpt(CLI::App &app) override
A result type that maintains a chainable sequence of errors for debugging and error reporting.
A Config implementation that lazily pulls a config value by consulting multiple priority-ordered back...
Abstract base class for applying text styling with context-aware formatting.
void register_config_options(CLI::App &app, CliOptionStorage &storage)
Registers all config options with a CLI11 App.
Storage struct for CLI option values.