SVCS - English Documentation
Loading...
Searching...
No Matches
svcs::cli::UndoCommand Class Reference

Command to revert the repository state to a previous commit. More...

#include <UndoCommand.hxx>

Inheritance diagram for svcs::cli::UndoCommand:
svcs::cli::ICommand

Public Member Functions

 UndoCommand (std::shared_ptr< ISubject > subject, std::shared_ptr< RepositoryManager > repoManager)
 Constructor for UndoCommand.
bool execute (const std::vector< std::string > &args) override
 Executes the undo command based on the provided arguments.
std::string getName () const override
 Gets the command's primary name.
std::string getDescription () const override
 Gets the short description of the command.
std::string getUsage () const override
 Gets the usage syntax of the command.
void showHelp () const override
 Displays detailed help information for the command.
Public Member Functions inherited from svcs::cli::ICommand
virtual ~ICommand ()=default
 Virtual destructor.

Detailed Description

Command to revert the repository state to a previous commit.

Implements the 'svcs undo' functionality. It uses the RepositoryManager to perform the actual history and working directory manipulation. It utilizes the ISubject (event bus) for user output and confirmation prompts.

Constructor & Destructor Documentation

◆ UndoCommand()

svcs::cli::UndoCommand::UndoCommand ( std::shared_ptr< ISubject > subject,
std::shared_ptr< RepositoryManager > repoManager )

Constructor for UndoCommand.

Parameters
subjectShared pointer to the event bus for communication (output, prompts).
repoManagerShared pointer to the RepositoryManager for core repository operations.

Member Function Documentation

◆ execute()

bool svcs::cli::UndoCommand::execute ( const std::vector< std::string > & args)
overridevirtual

Executes the undo command based on the provided arguments.

Parses arguments for a specific commit hash or the --force flag. If no hash is provided, it attempts to undo the last commit.

Parameters
argsThe command-line arguments (e.g., commit hash, –force).
Returns
true on successful execution (or if help is shown), false on error.

Implements svcs::cli::ICommand.

◆ getDescription()

std::string svcs::cli::UndoCommand::getDescription ( ) const
nodiscardoverridevirtual

Gets the short description of the command.

Returns
A string describing the command's function.

Implements svcs::cli::ICommand.

◆ getName()

std::string svcs::cli::UndoCommand::getName ( ) const
nodiscardoverridevirtual

Gets the command's primary name.

Returns
The string "undo".

Implements svcs::cli::ICommand.

◆ getUsage()

std::string svcs::cli::UndoCommand::getUsage ( ) const
nodiscardoverridevirtual

Gets the usage syntax of the command.

Returns
A string detailing how the command is used.

Implements svcs::cli::ICommand.

◆ showHelp()

void svcs::cli::UndoCommand::showHelp ( ) const
overridevirtual

Displays detailed help information for the command.

Implements svcs::cli::ICommand.


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