SVCS - English Documentation
Loading...
Searching...
No Matches
StatusCommand.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#include <filesystem>
23
37namespace svcs::cli {
38
39using namespace svcs::core;
40using namespace svcs::services;
41
43 * @english
44 * @brief Command for showing the current status of the repository.
45 * @details The StatusCommand displays:
46 * - Current branch
47 * - Staged changes (ready to save)
48 * - Unstaged changes (not yet added)
49 * - Untracked files (new files)
50 * - Status of specific files when provided as arguments
51 *
52 * @russian
53 * @brief Команда для отображения текущего статуса репозитория.
54 * @details StatusCommand отображает:
55 * - Текущую ветку
56 * - Подготовленные изменения (готовые к сохранению)
57 * - Неподготовленные изменения (еще не добавленные)
58 * - Неотслеживаемые файлы (новые файлы)
59 * - Статус конкретных файлов при предоставлении в качестве аргументов
60 */
61class StatusCommand : public ICommand {
62private:
70 std::shared_ptr<ISubject> eventBus_;
71
79 std::shared_ptr<RepositoryManager> repoManager_;
81public:
93 StatusCommand(std::shared_ptr<ISubject> subject,
94 std::shared_ptr<RepositoryManager> repoManager);
95
107 bool execute(const std::vector<std::string>& args) override;
108
118 [[nodiscard]] std::string getName() const override { return "status"; }
119
129 [[nodiscard]] std::string getDescription() const override;
130
140 [[nodiscard]] std::string getUsage() const override;
141
149 void showHelp() const override;
150
151private:
161 [[nodiscard]] bool showFullStatus() const;
162
174 [[nodiscard]] bool showFileStatus(const std::vector<std::string>& files) const;
175
181
183 void showBranchInfo() const;
184
192 void showStagedChanges() const;
193
201 void showUnstagedChanges() const;
202
210 void showUntrackedFiles() const;
211
221 [[nodiscard]] std::string getCurrentBranch() const;
222
234 [[nodiscard]] bool isFileModified(const std::filesystem::path& filePath) const;
235
245 [[nodiscard]] std::vector<std::filesystem::path> findUntrackedFiles() const;
246
260 [[nodiscard]] static std::string formatFileStatus(char status, const std::string& filePath);
261
273 [[nodiscard]] std::pair<char, std::string> getFileStatus(const std::string& filePath) const;
274};
275
276}
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.
Interface (abstract base class) for all commands executed via the CLI.
Definition ICommand.hxx:34
void showHelp() const override
Shows detailed help information for this command.
Definition StatusCommand.cxx:130
std::string getUsage() const override
Gets the usage syntax of the command.
Definition StatusCommand.cxx:126
std::string getName() const override
Gets the name of the command.
Definition StatusCommand.hxx:80
std::string getDescription() const override
Gets the description of the command.
Definition StatusCommand.cxx:122
StatusCommand(std::shared_ptr< ISubject > subject, std::shared_ptr< RepositoryManager > repoManager)
Constructs the StatusCommand.
Definition StatusCommand.cxx:26
bool execute(const std::vector< std::string > &args) override
Executes the status command.
Definition StatusCommand.cxx:31
Command-line interface components and command implementations.