23 cmd.add_option(
"<tileset-name>", tileset_name_,
"Name of the tileset to create (e.g., gTileset_MyTileset)")
25 cmd.add_flag(
"--secondary", secondary_,
"Create a secondary tileset instead of a primary.");
39 const auto env_result = env.initialize(tileset_name_);
40 if (!env_result.has_value()) {
44 env.stderr_diag.fatal(env_fail_result);
45 throw CLI::RuntimeError{1};
49 if (!attribute_context.has_value()) {
53 env.diag->fatal(fail_result);
54 throw CLI::RuntimeError{1};
61 const auto behavior_provider_it = services.
provider_map.find(attribute::field_behavior);
62 if (behavior_provider_it == services.provider_map.end()) {
64 "Cannot create a tileset: the resolved attribute schema has no provider-backed '{}' field.",
65 FormatParam{std::string{attribute::field_behavior}, Style::bold}}};
66 env.diag->fatal(no_behavior_err);
67 throw CLI::RuntimeError{1};
69 TilesetCreator creator{&env.config, behavior_provider_it->second.get()};
78 &services.metadata_provider,
79 &services.layout_metadata_provider,
80 &services.tileset_manager,
84 create_result = create_use_case.create(tileset_name_);
91 &services.metadata_provider,
92 &services.tileset_manager,
96 create_result = create_use_case.create(tileset_name_);
102 env.diag->fatal(fail_result);
103 throw CLI::RuntimeError{1};
107 static constexpr auto command_name =
"create-tileset";
108 static constexpr auto command_desc =
"Create a new Porytiles-managed tileset from scratch.";
109 static constexpr auto command_group =
"COMMANDS";
110 std::string tileset_name_;
111 bool secondary_ =
false;
Command is an abstract class that provides basic command functionality for the Porytiles CLI driver.
CLI::App & get_app() const
CreateTilesetCommand(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 creating a new primary Tileset from scratch.
Use case for creating a new secondary Tileset from scratch.
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.
Domain service for creating new tilesets from scratch.
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.