SVCS - English Documentation
Loading...
Searching...
No Matches
HistoryCommand.hxx
Go to the documentation of this file.
1
13#pragma once
14
15#include "ICommand.hxx"
18
19#include <memory>
20#include <vector>
21#include <string>
22
36namespace svcs::cli {
37
38using namespace svcs::core;
39
53class HistoryCommand : public ICommand {
54private:
62 std::shared_ptr<ISubject> eventBus_;
63
71 std::shared_ptr<RepositoryManager> repoManager_;
72
73public:
85 HistoryCommand(std::shared_ptr<ISubject> subject,
86 std::shared_ptr<RepositoryManager> repoManager);
87
103 bool execute(const std::vector<std::string>& args) override;
104
114 [[nodiscard]] std::string getName() const override { return "history"; }
115
125 [[nodiscard]] std::string getDescription() const override;
126
136 [[nodiscard]] std::string getUsage() const override;
137
145 void showHelp() const override;
146
147private:
150
165 bool parseArguments(const std::vector<std::string>& args,
166 bool& showOneline, int& limit, bool& showFull) const;
167
177 void showDefaultHistory(const std::vector<CommitInfo>& entries) const;
178
188 void showOnelineHistory(const std::vector<CommitInfo>& entries) const;
189
199 void showDetailedHistory(const std::vector<CommitInfo>& entries) const;
200
212 [[nodiscard]] static std::string formatTimestamp(const std::string& timestamp);
213
227 [[nodiscard]] static std::string truncateString(const std::string& str, size_t length);
228};
229
230}
Declaration of the ICommand interface for all executable CLI commands.
Defines the interface for the Subject (Publisher) component of the Observer pattern.
Declaration of the RepositoryManager class, managing all repository-level file operations.
HistoryCommand(std::shared_ptr< ISubject > subject, std::shared_ptr< RepositoryManager > repoManager)
Constructor for HistoryCommand.
Definition HistoryCommand.cxx:23
std::string getDescription() const override
Gets a brief description of the command.
Definition HistoryCommand.cxx:76
void showHelp() const override
Displays the detailed help information for the command.
Definition HistoryCommand.cxx:84
std::string getName() const override
Gets the name of the command.
Definition HistoryCommand.hxx:77
std::string getUsage() const override
Gets the command's usage syntax.
Definition HistoryCommand.cxx:80
bool execute(const std::vector< std::string > &args) override
Executes the "history" command with the given arguments.
Definition HistoryCommand.cxx:28
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.