lintel 0.2.0
Loading...
Searching...
No Matches
CommandLineService.h
Go to the documentation of this file.
1#ifndef LINTEL_COMMANDLINESERVICE_H
2#define LINTEL_COMMANDLINESERVICE_H
3
5
6
7#include <atomic>
8#include <map>
9#include <memory>
10#include <optional>
11#include <thread>
12#include <vector>
13
23
24namespace lintel {
25class CommandLineComponent;
26
28class CommandLineService : public AbstractService<CommandLineService>
29{
30private:
31 enum Commands { CommandHelp, CommandClear, CommandMenu, CommandHistory, CommandExit, CommandUndefined };
32
34 std::thread m_thread;
35 std::atomic<bool> m_running = true;
37 std::shared_ptr<AuthCliService> m_authCliService;
38 std::shared_ptr<UserApi> m_userApi;
39 std::shared_ptr<CommandLineUtils> m_commandLineUtils;
40 UserDto m_userDto;
41 std::shared_ptr<IInputService> m_inputService;
42 std::shared_ptr<ITerminalService> m_terminalService;
43 std::shared_ptr<CommandLineHistoryService> m_commandLineHistoryService;
44 std::optional<std::string> m_helpComponentName;
45
47 std::string menuNameOf();
48
50 void onComponentCommand(const std::string &input, const std::vector<std::string> &flags);
51
53 void onCommand(const std::string &input, const std::vector<std::string> &flags);
54
56 void onEndOfFile();
57
59 void onStart();
60
62 void onHelp();
63
65 void onPrompt();
66
68 void handleCommandInput(const SymbolEvent &symbolEvent, bool &tabPressed, bool &printPrompt);
69
71 void handleTabInput(const SymbolEvent &symbolEvent, bool &tabPressed, bool &printPrompt);
72
74 void run();
75
76public:
77 explicit CommandLineService(const std::vector<std::shared_ptr<CommandLineComponent>> &components,
78 std::shared_ptr<AuthCliService> authCliService,
79 std::shared_ptr<UserApi> userApi,
80 std::shared_ptr<CommandLineUtils> commandLineUtils,
81 std::shared_ptr<IInputService> inputService,
82 std::shared_ptr<ITerminalService> terminalService,
83 const std::shared_ptr<ProcessName> &processName,
84 std::shared_ptr<CommandLineHistoryService> commandLineHistoryService);
85
87
88 void onInitialize() override;
89
90 void onShutdown() override;
91};
92
93}// namespace lintel
94#endif// LINTEL_COMMANDLINESERVICE_H
Definition AbstractCommandLineMenu.h:14
Definition AbstractService.h:58
Definition CommandLineService.h:29
void onShutdown() override
CommandLineService(const std::vector< std::shared_ptr< CommandLineComponent > > &components, std::shared_ptr< AuthCliService > authCliService, std::shared_ptr< UserApi > userApi, std::shared_ptr< CommandLineUtils > commandLineUtils, std::shared_ptr< IInputService > inputService, std::shared_ptr< ITerminalService > terminalService, const std::shared_ptr< ProcessName > &processName, std::shared_ptr< CommandLineHistoryService > commandLineHistoryService)
void onInitialize() override
Definition CommandParser.h:21
Definition UserDto.h:16
Definition BaseFeature.h:6
std::pair< Symbol, std::string > SymbolEvent
Definition CliTypes.h:16
constexpr std::string_view type_name()
Definition TypeName.h:9