9#include "fruit/fruit.h"
39 :
Command{parent_app, kCommandName, kCommandDesc, kCommandGroup}
42 cmd.add_option(
"<tileset-name>", tileset_name_,
"Name of the tileset to compile")->required();
54 const bool no_color = !isatty(STDERR_FILENO);
55 fruit::Injector injector{di::get_formatter_component, no_color};
59 std::unique_ptr<UserDiagnostics> diag = std::make_unique<StderrStyledUserDiagnostics>(text_formatter);
60 std::unique_ptr<TilePrinter> tile_printer = std::make_unique<AsciiTilePrinter>(text_formatter);
64 std::vector<std::unique_ptr<ConfigProvider>> providers{};
65 providers.push_back(std::make_unique<YamlFileProvider>(text_formatter,
".", key_provider));
66 providers.push_back(std::make_unique<DefaultProvider>());
86 TilesetRepo repo{&checksum_provider, &key_provider, &artifact_reader, &artifact_writer};
89 auto maybe_tileset = repo.
load(tileset_name_);
90 if (!maybe_tileset.has_value()) {
91 diag->fatal(maybe_tileset);
94 const auto tileset = std::move(maybe_tileset.value());
97 auto compile_result = compiler.compile_patch_tiles_fixed_pals_fixed(*tileset);
98 if (!compile_result.has_value()) {
102 diag->fatal(fail_result);
105 const auto new_tileset = std::move(compile_result.value());
120 const auto new_tileset_save_result = repo.save(*new_tileset);
121 if (!new_tileset_save_result.has_value()) {
122 diag->fatal(new_tileset_save_result);
128 static constexpr auto kCommandName =
"debug-compile-primary";
129 static constexpr auto kCommandDesc =
130 "Load a tileset, run it through the compile-primary service, and write it back.";
131 static constexpr auto kCommandGroup =
"COMMANDS";
132 std::string tileset_name_;
Command is an abstract class that provides basic command functionality for the Porytiles CLI driver.
CLI::App & get_app() const
DebugPrimaryCompileCommand(CLI::App &parent_app)
A result type that maintains a chainable sequence of errors for debugging and error reporting.
An implementation of FilePalLoader that loads palettes from JASC-PAL (Paintshop Pro) pal files.
An implementation of FilePalSaver that saves palettes to JASC-PAL (Paintshop Pro) pal files.
A Config implementation that lazily pulls a config value by consulting multiple priority-ordered back...
An image loader that reads PNG files to create an Image with an index pixel type.
An image saver that saves PNG files from an Image with an index pixel type.
An image loader that reads PNG files to create an Image with an Rgba32 pixel type.
An image saver that saves PNG files from an Image with an Rgba32 pixel type.
Service that compiles a primary Tileset.
Provides a pokeemerald project filesystem-based implementation for TilesetArtifactKeyProvider.
Provides a filesystem-based implementation for TilesetArtifactReader.
Provides a filesystem-based implementation for TilesetArtifactWriter.
Abstract base class for applying text styling with context-aware formatting.
Repository interface for the Tileset aggregate root.
ChainableResult< std::unique_ptr< Tileset > > load(const std::string &name) const
Loads an existing Tileset from storage.