SVCS - Русская документация
Загрузка...
Поиск...
Не найдено
HelpService.hxx
См. документацию.
1
13#pragma once
14
16
17#include <memory>
18#include <vector>
19#include <string>
20#include <functional>
21
35namespace svcs::cli {
36
37using namespace svcs::services;
38
54class HelpService {
55private:
63 std::shared_ptr<ISubject> eventBus_;
64
65 // Callback functions instead of direct CommandFactory dependency
66
74 std::function<std::vector<std::string>()> getCommandsCallback_;
75
83 std::function<std::string(const std::string&)> getDescriptionCallback_;
84
92 std::function<void(const std::string&)> showHelpCallback_;
93
101 std::function<std::string(const std::string&)> getUsageCallback_;
102
103public:
112
121 HelpService(std::shared_ptr<ISubject> bus,
122 std::function<std::vector<std::string>()> getCommands,
123 std::function<std::string(const std::string&)> getDescription,
124 std::function<void(const std::string&)> showHelp,
125 std::function<std::string(const std::string&)> getUsage = nullptr);
126
136 [[nodiscard]] std::vector<std::string> getAvailableCommands() const;
137
149 [[nodiscard]] std::string getCommandDescription(const std::string& commandName) const;
150
160 void showCommandHelp(const std::string& commandName) const;
161
173 [[nodiscard]] bool commandExists(const std::string& commandName) const;
174
186 [[nodiscard]] std::string getCommandUsage(const std::string& commandName) const;
187};
188
189}
Определяет интерфейс для компонента Subject (Издатель) шаблона Observer.
HelpService(std::shared_ptr< ISubject > bus, std::function< std::vector< std::string >()> getCommands, std::function< std::string(const std::string &)> getDescription, std::function< void(const std::string &)> showHelp, std::function< std::string(const std::string &)> getUsage=nullptr)
Конструирует HelpService путем внедрения необходимых зависимостей в виде обратных вызовов.
Определения HelpService.cxx:21
std::vector< std::string > getAvailableCommands() const
Выполняет getCommandsCallback_ для получения списка всех доступных имен команд.
Определения HelpService.cxx:33
void showCommandHelp(const std::string &commandName) const
Выполняет showHelpCallback_ для запуска отображения подробной справки для конкретной команды.
Определения HelpService.cxx:47
bool commandExists(const std::string &commandName) const
Проверяет существование команды путем сравнения со списком, возвращенным getAvailableCommands.
Определения HelpService.cxx:56
std::string getCommandUsage(const std::string &commandName) const
Выполняет getUsageCallback_ для получения синтаксиса использования конкретной команды.
Определения HelpService.cxx:61
std::string getCommandDescription(const std::string &commandName) const
Выполняет getDescriptionCallback_ для получения краткого описания конкретной команды.
Определения HelpService.cxx:40
Компоненты командной строки и реализации команд.
Компоненты сервисного слоя и инфраструктурные сервисы.