yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::cli::resources::CommandContext Class Reference

Encapsulates common context for CLI command execution. More...

#include <command_context.h>

Collaboration diagram for yaze::cli::resources::CommandContext:

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_
 
Romactive_rom_ = nullptr
 
bool initialized_ = false
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CommandContext()

yaze::cli::resources::CommandContext::CommandContext ( const Config config)
explicit

Definition at line 26 of file command_context.cc.

◆ ~CommandContext()

yaze::cli::resources::CommandContext::~CommandContext ( )
default

Member Function Documentation

◆ Initialize()

absl::Status yaze::cli::resources::CommandContext::Initialize ( )

◆ 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().

Here is the call graph for this function:

◆ GetFormat()

const std::string & yaze::cli::resources::CommandContext::GetFormat ( ) const
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().

◆ IsVerbose()

bool yaze::cli::resources::CommandContext::IsVerbose ( ) const
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().

◆ EnsureLabelsLoaded()

absl::Status yaze::cli::resources::CommandContext::EnsureLabelsLoaded ( Rom rom)

Member Data Documentation

◆ config_

Config yaze::cli::resources::CommandContext::config_
private

Definition at line 67 of file command_context.h.

Referenced by GetFormat(), Initialize(), and IsVerbose().

◆ rom_storage_

Rom yaze::cli::resources::CommandContext::rom_storage_
private

Definition at line 68 of file command_context.h.

Referenced by Initialize().

◆ active_rom_

Rom* yaze::cli::resources::CommandContext::active_rom_ = nullptr
private

Definition at line 69 of file command_context.h.

Referenced by GetRom(), and Initialize().

◆ initialized_

bool yaze::cli::resources::CommandContext::initialized_ = false
private

Definition at line 70 of file command_context.h.

Referenced by GetRom(), and Initialize().


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