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 ()=default | |
absl::Status | Initialize () |
Initialize the context and load ROM if needed. | |
absl::StatusOr< Rom * > | GetRom () |
Get the ROM instance (loads if not already loaded) | |
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. | |
Private Attributes | |
Config | config_ |
Rom | rom_storage_ |
Rom * | active_rom_ = nullptr |
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 23 of file command_context.h.
|
explicit |
Definition at line 26 of file command_context.cc.
|
default |
absl::Status yaze::cli::resources::CommandContext::Initialize | ( | ) |
Initialize the context and load ROM if needed.
Definition at line 28 of file command_context.cc.
References active_rom_, config_, yaze::cli::resources::CommandContext::Config::external_rom_context, initialized_, yaze::cli::InitializeMockRom(), yaze::Rom::is_loaded(), yaze::Rom::LoadFromFile(), yaze::cli::resources::CommandContext::Config::rom_path, rom_storage_, and yaze::cli::resources::CommandContext::Config::use_mock_rom.
Referenced by GetRom().
absl::StatusOr< Rom * > yaze::cli::resources::CommandContext::GetRom | ( | ) |
Get the ROM instance (loads if not already loaded)
Definition at line 83 of file command_context.cc.
References active_rom_, Initialize(), and initialized_.
Referenced by yaze::cli::resources::CommandHandler::Run(), yaze::cli::resources::TEST_F(), yaze::cli::resources::TEST_F(), yaze::cli::resources::TEST_F(), and yaze::cli::resources::TEST_F().
|
inline |
Get the output format ("json" or "text")
Definition at line 54 of file command_context.h.
References config_, and yaze::cli::resources::CommandContext::Config::format.
Referenced by yaze::cli::resources::TEST_F().
|
inline |
Check if verbose mode is enabled.
Definition at line 59 of file command_context.h.
References config_, and yaze::cli::resources::CommandContext::Config::verbose.
Referenced by yaze::cli::resources::TEST_F().
absl::Status yaze::cli::resources::CommandContext::EnsureLabelsLoaded | ( | Rom * | rom | ) |
Ensure resource labels are loaded.
Definition at line 98 of file command_context.cc.
References yaze::core::YazeProject::InitializeEmbeddedLabels(), yaze::core::ResourceLabelManager::labels_, yaze::core::ResourceLabelManager::labels_loaded_, yaze::Rom::resource_label(), yaze::core::YazeProject::resource_labels, and yaze::core::YazeProject::use_embedded_labels.
Referenced by yaze::cli::resources::CommandHandler::Run(), and yaze::cli::resources::TEST_F().
|
private |
Definition at line 67 of file command_context.h.
Referenced by GetFormat(), Initialize(), and IsVerbose().
|
private |
Definition at line 68 of file command_context.h.
Referenced by Initialize().
|
private |
Definition at line 69 of file command_context.h.
Referenced by GetRom(), and Initialize().
|
private |
Definition at line 70 of file command_context.h.
Referenced by GetRom(), and Initialize().