lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
lintel::CommandLineComponent Class Referenceabstract

#include <CommandLineComponent.h>

Inheritance diagram for lintel::CommandLineComponent:
lintel::HistoryCliComponent lintel::MessageQueueCliComponent lintel::ProcessCliComponent lintel::PropertyCliComponent lintel::SharedMemoryCliComponent lintel::UserManagementCliComponent

Public Member Functions

 CommandLineComponent (std::string_view name, std::string_view alias)
 
virtual ~CommandLineComponent ()=default
 
std::string_view getName ()
 
std::string_view getAlias ()
 
virtual void onCommand (const UserDto &userDto, const std::string &command, const std::vector< std::string > &parameters)=0
 
virtual void onHelp ()=0
 
virtual void onShowMenu ()=0
 
virtual bool onMenu (const std::string &component)=0
 
virtual bool onExit ()=0
 
virtual void printCommandList (std::set< std::string > menuAlias)=0
 
virtual std::set< std::string > menuEntriesOf ()
 
virtual std::vector< std::string > allCommandsOf ()=0
 

Detailed Description

Abstract base class for all CLI components (menus/screens)

Constructor & Destructor Documentation

◆ CommandLineComponent()

lintel::CommandLineComponent::CommandLineComponent ( std::string_view  name,
std::string_view  alias 
)
Parameters
namedisplay name of the component
aliasshort alias for navigation

◆ ~CommandLineComponent()

virtual lintel::CommandLineComponent::~CommandLineComponent ( )
virtualdefault

Member Function Documentation

◆ allCommandsOf()

virtual std::vector< std::string > lintel::CommandLineComponent::allCommandsOf ( )
pure virtual

◆ getAlias()

std::string_view lintel::CommandLineComponent::getAlias ( )
Returns
component alias

◆ getName()

std::string_view lintel::CommandLineComponent::getName ( )
Returns
component display name

◆ menuEntriesOf()

virtual std::set< std::string > lintel::CommandLineComponent::menuEntriesOf ( )
inlinevirtual
Returns
set of sub-menu entries

Empty by default: a component without sub-menus (every built-in one) does not override this, and the menu loop treats the empty set as "nothing to navigate into". Components that do build a hierarchy override it.

◆ onCommand()

virtual void lintel::CommandLineComponent::onCommand ( const UserDto &  userDto,
const std::string &  command,
const std::vector< std::string > &  parameters 
)
pure virtual

◆ onExit()

virtual bool lintel::CommandLineComponent::onExit ( )
pure virtual
Returns
true if exit was confirmed

CommandLineService currently discards the result and exits either way; a component that can veto the exit overrides this.

Implemented in lintel::HistoryCliComponent, lintel::MessageQueueCliComponent, lintel::ProcessCliComponent, lintel::PropertyCliComponent, lintel::SharedMemoryCliComponent, and lintel::UserManagementCliComponent.

◆ onHelp()

virtual void lintel::CommandLineComponent::onHelp ( )
pure virtual

◆ onMenu()

virtual bool lintel::CommandLineComponent::onMenu ( const std::string &  component)
pure virtual
Parameters
componentname to navigate to; return true if handled

Reached with input that CommandParser could not classify, i.e. with a free-text line rather than a real command. CommandLineService prints "Invalid command" for a component that returns false, so a component without sub-menus returns false - returning true unconditionally would swallow every typo at the prompt without a word.

Implemented in lintel::HistoryCliComponent, lintel::MessageQueueCliComponent, lintel::ProcessCliComponent, lintel::PropertyCliComponent, lintel::SharedMemoryCliComponent, and lintel::UserManagementCliComponent.

◆ onShowMenu()

virtual void lintel::CommandLineComponent::onShowMenu ( )
pure virtual

◆ printCommandList()

virtual void lintel::CommandLineComponent::printCommandList ( std::set< std::string >  menuAlias)
pure virtual

The documentation for this class was generated from the following file: