Encapsulates common context for CLI command execution. More...
#include <command_context.h>

Classes | |
| struct | Config |
| Configuration for command context. More... | |
Public Member Functions | |
| CommandContext (const Config &config) | |
| ~CommandContext () | |
| absl::Status | Initialize () |
| Initialize the context and load ROM if needed. | |
| absl::StatusOr< Rom * > | GetRom () |
| Get the ROM instance (loads if not already loaded) | |
| emu::debug::SymbolProvider * | GetSymbolProvider () |
| Get the SymbolProvider instance. | |
| const std::string & | GetFormat () const |
| Get the output format ("json" or "text") | |
| bool | IsVerbose () const |
| Check if verbose mode is enabled. | |
| absl::Status | EnsureLabelsLoaded (Rom *rom) |
| Ensure resource labels are loaded. | |
| project::YazeProject * | GetProjectContext () |
| Returns loaded project context when –project-context was used. | |
Private Member Functions | |
| absl::Status | ApplyProjectRuntimeContext () |
| void | RestoreProjectRuntimeContext () |
Private Attributes | |
| Config | config_ |
| Rom | rom_storage_ |
| Rom * | active_rom_ |
| emu::debug::SymbolProvider | symbol_provider_ |
| std::optional< project::YazeProject > | loaded_project_ |
| std::optional< core::FeatureFlags::Flags > | previous_feature_flags_ |
| std::optional< zelda3::CustomObjectManager::State > | previous_custom_object_state_ |
| bool | project_runtime_applied_ = false |
| bool | initialized_ = false |
Encapsulates common context for CLI command execution.
Provides unified ROM loading, argument parsing, and common options management to reduce duplication across command handlers.
Definition at line 27 of file command_context.h.
|
explicit |
Definition at line 41 of file command_context.cc.
| yaze::cli::resources::CommandContext::~CommandContext | ( | ) |
Definition at line 43 of file command_context.cc.
References RestoreProjectRuntimeContext().

| absl::Status yaze::cli::resources::CommandContext::Initialize | ( | ) |
Initialize the context and load ROM if needed.
Definition at line 47 of file command_context.cc.
References active_rom_, ApplyProjectRuntimeContext(), config_, yaze::cli::resources::CommandContext::Config::external_rom_context, yaze::emu::debug::SymbolProvider::HasSymbols(), initialized_, yaze::cli::InitializeMockRom(), yaze::Rom::is_loaded(), yaze::Rom::LoadFromFile(), yaze::emu::debug::SymbolProvider::LoadSymbolFile(), yaze::cli::resources::CommandContext::Config::rom_path, rom_storage_, symbol_provider_, yaze::cli::resources::CommandContext::Config::symbols_path, yaze::cli::resources::CommandContext::Config::use_mock_rom, and yaze::cli::resources::CommandContext::Config::verbose.
Referenced by GetRom(), and GetSymbolProvider().
| absl::StatusOr< Rom * > yaze::cli::resources::CommandContext::GetRom | ( | ) |
Get the ROM instance (loads if not already loaded)
Definition at line 121 of file command_context.cc.
References active_rom_, Initialize(), and initialized_.
Referenced by yaze::cli::resources::CommandHandler::Run().

| emu::debug::SymbolProvider * yaze::cli::resources::CommandContext::GetSymbolProvider | ( | ) |
Get the SymbolProvider instance.
Definition at line 136 of file command_context.cc.
References Initialize(), initialized_, and symbol_provider_.
Referenced by yaze::cli::resources::CommandHandler::Run().

|
inline |
Get the output format ("json" or "text")
Definition at line 65 of file command_context.h.
References config_, and yaze::cli::resources::CommandContext::Config::format.
|
inline |
Check if verbose mode is enabled.
Definition at line 70 of file command_context.h.
References config_, and yaze::cli::resources::CommandContext::Config::verbose.
| absl::Status yaze::cli::resources::CommandContext::EnsureLabelsLoaded | ( | Rom * | rom | ) |
Ensure resource labels are loaded.
Definition at line 143 of file command_context.cc.
References yaze::project::YazeProject::InitializeEmbeddedLabels(), yaze::project::ResourceLabelManager::labels_, yaze::project::ResourceLabelManager::labels_loaded_, yaze::Rom::resource_label(), yaze::project::YazeProject::resource_labels, yaze::zelda3::Zelda3Labels::ToResourceLabels(), and yaze::project::YazeProject::use_embedded_labels.
Referenced by yaze::cli::resources::CommandHandler::Run().

|
inline |
Returns loaded project context when –project-context was used.
Definition at line 80 of file command_context.h.
References loaded_project_.
Referenced by yaze::cli::resources::CommandHandler::Run().
|
private |
Definition at line 165 of file command_context.cc.
References yaze::zelda3::CustomObjectManager::ClearObjectFileMap(), config_, yaze::project::YazeProject::feature_flags, yaze::core::FeatureFlags::get(), yaze::zelda3::CustomObjectManager::Get(), yaze::zelda3::DrawRoutineRegistry::Get(), yaze::zelda3::CustomObjectManager::Initialize(), yaze::core::FeatureFlags::Flags::kEnableCustomObjects, loaded_project_, yaze::project::YazeProject::Open(), previous_custom_object_state_, previous_feature_flags_, yaze::cli::resources::CommandContext::Config::project_context_path, project_runtime_applied_, yaze::zelda3::DrawRoutineRegistry::RefreshFeatureFlagMappings(), yaze::zelda3::CustomObjectManager::SetObjectFileMap(), yaze::zelda3::CustomObjectManager::SnapshotState(), and yaze::cli::resources::CommandContext::Config::verbose.
Referenced by Initialize().
|
private |
Definition at line 224 of file command_context.cc.
References yaze::core::FeatureFlags::get(), yaze::zelda3::CustomObjectManager::Get(), yaze::zelda3::DrawRoutineRegistry::Get(), loaded_project_, previous_custom_object_state_, previous_feature_flags_, project_runtime_applied_, yaze::zelda3::DrawRoutineRegistry::RefreshFeatureFlagMappings(), and yaze::zelda3::CustomObjectManager::RestoreState().
Referenced by ~CommandContext().
|
private |
Definition at line 88 of file command_context.h.
Referenced by ApplyProjectRuntimeContext(), GetFormat(), Initialize(), and IsVerbose().
|
private |
Definition at line 89 of file command_context.h.
Referenced by Initialize().
|
private |
Definition at line 90 of file command_context.h.
Referenced by GetRom(), and Initialize().
|
private |
Definition at line 92 of file command_context.h.
Referenced by GetSymbolProvider(), and Initialize().
|
private |
Definition at line 93 of file command_context.h.
Referenced by ApplyProjectRuntimeContext(), GetProjectContext(), and RestoreProjectRuntimeContext().
|
private |
Definition at line 94 of file command_context.h.
Referenced by ApplyProjectRuntimeContext(), and RestoreProjectRuntimeContext().
|
private |
Definition at line 96 of file command_context.h.
Referenced by ApplyProjectRuntimeContext(), and RestoreProjectRuntimeContext().
|
private |
Definition at line 97 of file command_context.h.
Referenced by ApplyProjectRuntimeContext(), and RestoreProjectRuntimeContext().
|
private |
Definition at line 98 of file command_context.h.
Referenced by GetRom(), GetSymbolProvider(), and Initialize().