Porytiles
Loading...
Searching...
No Matches
porytiles::TilesetCommandEnv Class Reference

Bootstrap class so every tileset command can share common config and diagnostic setup. More...

#include <tileset_command_setup.hpp>

Collaboration diagram for porytiles::TilesetCommandEnv:
[legend]

Public Member Functions

 TilesetCommandEnv (std::filesystem::path root, const CliOptionStorage &cli_storage)
 
ChainableResult< void > initialize (const std::string &tileset_name)
 Runs the fallible half of env setup: YAML validation and the diagnostic filter construction.
 
 TilesetCommandEnv (const TilesetCommandEnv &)=delete
 
TilesetCommandEnvoperator= (const TilesetCommandEnv &)=delete
 
 TilesetCommandEnv (TilesetCommandEnv &&)=delete
 
TilesetCommandEnvoperator= (TilesetCommandEnv &&)=delete
 

Public Attributes

std::filesystem::path project_root
 
fruit::Injector< TextFormatterinjector
 
TextFormattertext_formatter
 
StderrStyledUserDiagnostics stderr_diag
 
gsl::not_null< YamlFileProvider * > yaml_provider
 
LazyLayeredConfig config
 
std::unique_ptr< FilteredUserDiagnosticsdiag
 

Detailed Description

Bootstrap class so every tileset command can share common config and diagnostic setup.

Owns the formatter injector, the unfiltered stderr diagnostics used during config loading, the layered config, and the filtered diagnostics built from the config's diagnostic include/exclude patterns.

Setup is two-phase: the constructor builds the infallible pieces, and initialize() runs the fallible half (YAML validation and the diagnostic filter construction) and returns a ChainableResult the command wraps with its own "Failed to <verb> tileset ..." context. Until initialize() succeeds, diag is unset, so failures report through stderr_diag.

Members hold pointers into earlier members, so the class is not copyable and not movable. Commands should construct it once on the stack.

Definition at line 72 of file tileset_command_setup.hpp.

Constructor & Destructor Documentation

◆ TilesetCommandEnv() [1/3]

porytiles::TilesetCommandEnv::TilesetCommandEnv ( std::filesystem::path  root,
const CliOptionStorage cli_storage 
)
inline

Definition at line 113 of file tileset_command_setup.hpp.

◆ TilesetCommandEnv() [2/3]

porytiles::TilesetCommandEnv::TilesetCommandEnv ( const TilesetCommandEnv )
delete

◆ TilesetCommandEnv() [3/3]

porytiles::TilesetCommandEnv::TilesetCommandEnv ( TilesetCommandEnv &&  )
delete

Member Function Documentation

◆ initialize()

ChainableResult< void > porytiles::TilesetCommandEnv::initialize ( const std::string &  tileset_name)
inline

Runs the fallible half of env setup: YAML validation and the diagnostic filter construction.

YAML validation failures return an error whose per-key details were already emitted through stderr_diag by the provider. An invalid diagnostic filter key is a real config error and fails the command too, instead of silently running with empty filters. On success, diag is ready for every subsequent operation.

Parameters
tileset_nameThe command's target tileset, used as the config scope
Returns
Nothing on success, or the error for the command to wrap with its own context

Definition at line 131 of file tileset_command_setup.hpp.

◆ operator=() [1/2]

TilesetCommandEnv & porytiles::TilesetCommandEnv::operator= ( const TilesetCommandEnv )
delete

◆ operator=() [2/2]

TilesetCommandEnv & porytiles::TilesetCommandEnv::operator= ( TilesetCommandEnv &&  )
delete

Member Data Documentation

◆ config

LazyLayeredConfig porytiles::TilesetCommandEnv::config

Definition at line 178 of file tileset_command_setup.hpp.

◆ diag

std::unique_ptr<FilteredUserDiagnostics> porytiles::TilesetCommandEnv::diag

Definition at line 179 of file tileset_command_setup.hpp.

◆ injector

fruit::Injector<TextFormatter> porytiles::TilesetCommandEnv::injector

Definition at line 166 of file tileset_command_setup.hpp.

◆ project_root

std::filesystem::path porytiles::TilesetCommandEnv::project_root

Definition at line 165 of file tileset_command_setup.hpp.

◆ stderr_diag

StderrStyledUserDiagnostics porytiles::TilesetCommandEnv::stderr_diag

Definition at line 168 of file tileset_command_setup.hpp.

◆ text_formatter

TextFormatter* porytiles::TilesetCommandEnv::text_formatter

Definition at line 167 of file tileset_command_setup.hpp.

◆ yaml_provider

gsl::not_null<YamlFileProvider *> porytiles::TilesetCommandEnv::yaml_provider

Definition at line 177 of file tileset_command_setup.hpp.


The documentation for this class was generated from the following file: