SVCS - English Documentation
Loading...
Searching...
No Matches
BranchCommand.hxx
Go to the documentation of this file.
1
21#pragma once
22
23#include "ICommand.hxx"
26
27#include <string>
28#include <vector>
29#include <memory>
30
42 * включая AddCommand, CommitCommand, StatusCommand и другие.
43 */
44namespace svcs::cli {
45
46using namespace svcs::core;
47
61class BranchCommand : public ICommand {
62public:
74 BranchCommand(std::shared_ptr<ISubject> event_bus,
75 std::shared_ptr<BranchManager> branch_manager);
76
84 ~BranchCommand() override = default;
85
95 [[nodiscard]] std::string getName() const override;
96
106 [[nodiscard]] std::string getDescription() const override;
107
117 [[nodiscard]] std::string getUsage() const override;
118
130 bool execute(const std::vector<std::string>& args) override;
131
139 void showHelp() const override;
140
141private:
151 bool listBranches() const;
152
164 bool createBranch(const std::string& branch_name) const;
165
179 bool createBranchFromCommit(const std::string& branch_name, const std::string& commit_hash) const;
180
189
194 bool deleteBranch(const std::string& branch_name, bool force = false) const;
195
209 bool renameBranch(const std::string& old_name, const std::string& new_name) const;
210
220 bool showCurrentBranch() const;
221
233 bool switchBranch(const std::string& branch_name) const;
234
246 [[nodiscard]] static bool isValidBranchName(const std::string& name);
247
259 [[nodiscard]] bool branchExists(const std::string& name) const;
260
272 [[nodiscard]] static bool isValidCommitHash(const std::string& hash);
273
274private:
282 std::shared_ptr<ISubject> event_bus_;
283
291 std::shared_ptr<BranchManager> branch_manager_;
292};
293
294}
Declaration of the BranchManager class for handling version control branches.
Declaration of the ICommand interface for all executable CLI commands.
Defines the interface for the Subject (Publisher) component of the Observer pattern.
std::string getUsage() const override
Gets the command usage syntax.
Definition BranchCommand.cxx:38
~BranchCommand() override=default
Destructor.
std::string getName() const override
Gets the command name.
Definition BranchCommand.cxx:30
std::string getDescription() const override
Gets the command description.
Definition BranchCommand.cxx:34
BranchCommand(std::shared_ptr< ISubject > event_bus, std::shared_ptr< BranchManager > branch_manager)
Constructor for BranchCommand.
Definition BranchCommand.cxx:25
bool execute(const std::vector< std::string > &args) override
Executes the branch command with given arguments.
Definition BranchCommand.cxx:92
void showHelp() const override
Displays help information for the command.
Definition BranchCommand.cxx:192
Interface (abstract base class) for all commands executed via the CLI.
Definition ICommand.hxx:34
Command-line interface components and command implementations.
Core VCS data structures and object model.