21 :
Command{parent_app, command_name, command_desc, command_group}
24 cmd.add_option(
"<tileset-name>", tileset_name_,
"Name of the tileset to compile")->required();
38 const auto env_result = env.initialize(tileset_name_);
39 if (!env_result.has_value()) {
43 env.stderr_diag.fatal(env_fail_result);
44 throw CLI::RuntimeError{1};
48 if (!attribute_context.has_value()) {
52 env.diag->fatal(fail_result);
53 throw CLI::RuntimeError{1};
58 if (!services.metadata_provider.exists(tileset_name_)) {
60 "Tileset '{}' does not exist. Create or import it first.",
FormatParam{tileset_name_, Style::bold}}};
61 env.diag->fatal(not_found_err);
62 throw CLI::RuntimeError{1};
66 auto is_secondary_result = services.metadata_provider.is_secondary(tileset_name_);
67 if (!is_secondary_result.has_value()) {
71 env.diag->fatal(fail_result);
72 throw CLI::RuntimeError{1};
76 if (is_secondary_result.value()) {
80 &services.metadata_provider,
81 &services.layout_metadata_provider,
82 &services.tileset_manager,
86 compile_result = compile_use_case.compile(tileset_name_);
92 &services.metadata_provider,
93 &services.tileset_manager,
97 compile_result = compile_use_case.compile(tileset_name_);
103 env.diag->fatal(fail_result);
104 throw CLI::RuntimeError{1};
108 static constexpr auto command_name =
"compile-tileset";
109 static constexpr auto command_desc =
110 "Compile a tileset -- update the Porymap assets to match the Porytiles assets.";
111 static constexpr auto command_group =
"COMMANDS";
112 std::string tileset_name_;
Command is an abstract class that provides basic command functionality for the Porytiles CLI driver.
CLI::App & get_app() const
CompileTilesetCommand(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.
bool has_value() const
Checks whether the result contains a success value.
Use case for compiling a primary Tileset.
Use case for compiling a secondary Tileset.
Bootstrap class so every tileset command can share common config and diagnostic setup.
The schema-driven service graph shared by the compile, create, import, and decompile commands.
void register_config_options(CLI::App &app, CliOptionStorage &storage)
Registers all config options with a CLI11 App.
ChainableResult< ResolvedAttributeContext > resolve_attribute_context(TilesetCommandEnv &env, const std::string &tileset_name)
Resolves the invocation's metatile attribute schema and builds the provider map for its fields.
Storage struct for CLI option values.