Base class for all CLI commands.
More...
#include <BaseCommand.hxx>
|
| | BaseCommand (std::shared_ptr< ISubject > subject) |
| | Constructor.
|
| | ~BaseCommand () override=default |
| | Virtual destructor.
|
| virtual std::string | getName () const override=0 |
| | Gets the command name (e.g., "init", "commit").
|
| virtual std::string | getDescription () const override=0 |
| | Gets a brief description of the command.
|
| virtual std::string | getUsage () const override=0 |
| | Gets the command's usage syntax.
|
| void | showHelp () const override |
| | Displays the command's help (Usage and Description).
|
| void | logDebug (const std::string &message) const |
| | Generates a debug information event (DEBUG_MESSAGE).
|
| void | logInfo (const std::string &message) const |
| | Generates a general informational event (GENERAL_INFO).
|
| void | logError (const std::string &message) const |
| | Generates a runtime error event (RUNTIME_ERROR).
|
| void | logSuccess (const std::string &message) const |
| | Generates a successful execution event (GENERAL_INFO with SUCCESS prefix).
|
| void | logWarning (const std::string &message) const |
| | Generates a warning event (RUNTIME_ERROR with WARNING prefix).
|
| Public Member Functions inherited from svcs::cli::ICommand |
| virtual | ~ICommand ()=default |
| | Virtual destructor.
|
| virtual bool | execute (const std::vector< std::string > &args)=0 |
| | Executes the main logic of the command.
|
Base class for all CLI commands.
Provides a common infrastructure for interacting with the Event Bus system (ISubject) and utility methods for working with the repository. It is responsible for logging via the Event Bus.
◆ BaseCommand()
| svcs::cli::BaseCommand::BaseCommand |
( |
std::shared_ptr< ISubject > | subject | ) |
|
|
inline |
Constructor.
- Parameters
-
| subject | The ISubject (Event Bus) instance that will be used for generating events and logs. |
◆ ~BaseCommand()
| svcs::cli::BaseCommand::~BaseCommand |
( |
| ) |
|
|
overridedefault |
Virtual destructor.
Ensures correct cleanup of derived classes.
◆ createRepository()
| std::shared_ptr< Repository > svcs::cli::BaseCommand::createRepository |
( |
const std::string & | path = "." | ) |
|
|
inlinestaticprotected |
Creates a new repository instance.
- Parameters
-
| path | The path where the repository should be created (defaults to '.'). |
- Returns
- A smart pointer to the new Repository.
◆ findRepository()
| std::shared_ptr< Repository > svcs::cli::BaseCommand::findRepository |
( |
| ) |
|
|
inlinestaticprotected |
Finds an existing repository in the current or parent directories.
- Returns
- A smart pointer to the found Repository or nullptr if no repository is found.
◆ getDescription()
| virtual std::string svcs::cli::BaseCommand::getDescription |
( |
| ) |
const |
|
overridepure virtual |
Gets a brief description of the command.
- Returns
- The command's description.
Implements svcs::cli::ICommand.
◆ getName()
| virtual std::string svcs::cli::BaseCommand::getName |
( |
| ) |
const |
|
overridepure virtual |
Gets the command name (e.g., "init", "commit").
- Returns
- The command name as a string.
Implements svcs::cli::ICommand.
◆ getUsage()
| virtual std::string svcs::cli::BaseCommand::getUsage |
( |
| ) |
const |
|
overridepure virtual |
Gets the command's usage syntax.
- Returns
- A string with the syntax (e.g., "vcs init <path>").
Implements svcs::cli::ICommand.
◆ logDebug()
| void svcs::cli::BaseCommand::logDebug |
( |
const std::string & | message | ) |
const |
|
inline |
Generates a debug information event (DEBUG_MESSAGE).
- Parameters
-
| message | The text of the debug message. |
◆ logError()
| void svcs::cli::BaseCommand::logError |
( |
const std::string & | message | ) |
const |
|
inline |
Generates a runtime error event (RUNTIME_ERROR).
- Parameters
-
| message | The text of the error message. |
◆ logInfo()
| void svcs::cli::BaseCommand::logInfo |
( |
const std::string & | message | ) |
const |
|
inline |
Generates a general informational event (GENERAL_INFO).
- Parameters
-
| message | The text of the informational message. |
◆ logSuccess()
| void svcs::cli::BaseCommand::logSuccess |
( |
const std::string & | message | ) |
const |
|
inline |
Generates a successful execution event (GENERAL_INFO with SUCCESS prefix).
- Parameters
-
| message | The text of the successful execution message. |
◆ logWarning()
| void svcs::cli::BaseCommand::logWarning |
( |
const std::string & | message | ) |
const |
|
inline |
Generates a warning event (RUNTIME_ERROR with WARNING prefix).
- Parameters
-
| message | The text of the warning message. |
◆ showHelp()
| void svcs::cli::BaseCommand::showHelp |
( |
| ) |
const |
|
inlineoverridevirtual |
Displays the command's help (Usage and Description).
This method outputs information directly to the standard output stream (stdout).
Implements svcs::cli::ICommand.
◆ eventSubject_
| std::shared_ptr<ISubject> svcs::cli::BaseCommand::eventSubject_ |
|
protected |
The Event Subject (Event Bus) instance.
Used to generate events (logs) that will be received by observers, such as the Logger.
The documentation for this class was generated from the following file: