SVCS - English Documentation
Loading...
Searching...
No Matches
AddCommand.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
35 */
36namespace svcs::cli {
37
38using namespace svcs::core;
39
47enum class FileStatus {
56
60
65
71 * @brief Файл отслеживается, но был удален из рабочей директории.
72 */
73 DELETED,
74
83};
84
104class AddCommand : public ICommand {
105private:
106 std::shared_ptr<ISubject> eventBus_;
107 std::shared_ptr<RepositoryManager> repoManager_;
108
116 struct AddOptions {
124 bool dryRun = false;
125
133 bool interactive = false;
134
142 bool patch = false;
143
151 bool update = false;
152
160 bool force = false;
161
169 bool showHelp = false;
170
178 std::vector<std::string> files;
179
187 std::vector<std::string> excludePatterns;
188 };
189
190 // New methods
200 [[nodiscard]] bool addInteractive() const;
201
213 [[nodiscard]] bool addPatch(const std::string& filePath) const;
214
225
226 [[nodiscard]] bool showDryRun(const std::vector<std::string>& files) const;
227
241 [[nodiscard]] bool shouldAddFile(const std::string& file, bool force) const;
242
243 // Argument Parsing
255 [[nodiscard]] AddOptions parseArguments(const std::vector<std::string>& args) const;
256
257public:
269 AddCommand(std::shared_ptr<ISubject> subject,
270 std::shared_ptr<RepositoryManager> repoManager);
271
283 bool execute(const std::vector<std::string>& args) override;
284
296 [[nodiscard]] std::vector<std::string> getAllFilesInDirectory(const std::string& directory) const;
297
307 [[nodiscard]] std::string getName() const override { return "add"; }
308
318 [[nodiscard]] std::string getDescription() const override;
319
329 [[nodiscard]] std::string getUsage() const override;
330
338 void showHelp() const override;
339};
340
341}
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.
Implements the "add" command for the Simple Version Control System (SVCS).
Definition AddCommand.hxx:71
void showHelp() const override
Displays the detailed help information for the command.
Definition AddCommand.cxx:296
bool execute(const std::vector< std::string > &args) override
Executes the "add" command with the given arguments.
Definition AddCommand.cxx:58
std::string getName() const override
Gets the name of the command.
Definition AddCommand.hxx:203
std::vector< std::string > getAllFilesInDirectory(const std::string &directory) const
Retrieves all file paths within a given directory, recursively.
Definition AddCommand.cxx:269
AddCommand(std::shared_ptr< ISubject > subject, std::shared_ptr< RepositoryManager > repoManager)
Constructor for AddCommand.
Definition AddCommand.cxx:20
std::string getUsage() const override
Gets the command's usage syntax.
Definition AddCommand.cxx:292
std::string getDescription() const override
Gets a brief description of the command.
Definition AddCommand.cxx:288
Interface (abstract base class) for all commands executed via the CLI.
Definition ICommand.hxx:34
Command-line interface components and command implementations.
FileStatus
Defines the status of a file within the SVCS.
Definition AddCommand.hxx:35
@ MODIFIED
File is tracked and has been modified since the last commit.
Definition AddCommand.hxx:46
@ DELETED
File is tracked but has been deleted from the working directory.
Definition AddCommand.hxx:52
@ UNMODIFIED
File is tracked and has no changes since the last commit.
Definition AddCommand.hxx:58
@ UNTRACKED
File is present but not tracked by SVCS.
Definition AddCommand.hxx:40
Core VCS data structures and object model.