BashSpark
Loading...
Searching...
No Matches
bs::command Class Referenceabstract

Abstract base class for all shell commands. More...

#include <command.h>

Inheritance diagram for bs::command:

Public Member Functions

 command (std::string sName)
 Construct a command with a given name.
 
virtual ~command ()=default
 Virtual destructor.
 
virtual shell_status run (const std::span< const std::string > &vArgs, shell_session &oSession) const =0
 Execute the command.
 
std::string get_name () const
 Get the command name (copy).
 
const std::string & get_name_ref () const noexcept
 Get the command name (reference).
 

Friends

class shell
 

Detailed Description

Abstract base class for all shell commands.

Encapsulates a shell command's identity and execution interface. Every command must implement run() to perform its action. Commands may be extended to provide custom error reporting.

Constructor & Destructor Documentation

◆ command()

bs::command::command ( std::string  sName)
inlineexplicit

Construct a command with a given name.

Parameters
sNameThe command's name.

Member Function Documentation

◆ get_name()

std::string bs::command::get_name ( ) const
inline

Get the command name (copy).

Returns
Command name.

◆ get_name_ref()

const std::string & bs::command::get_name_ref ( ) const
inlinenoexcept

Get the command name (reference).

Returns
Reference to command name string.

◆ run()

virtual shell_status bs::command::run ( const std::span< const std::string > &  vArgs,
shell_session oSession 
) const
pure virtual

Execute the command.

Parameters
vArgsArguments for the command.
oSessionThe shell session context.
Returns
Status of command execution.

Implemented in bs::command_echo, bs::command_eval, bs::command_getenv, bs::command_setenv, bs::command_fcall, bs::command_math, bs::command_seq, bs::command_test, bs::command_getvar, and bs::command_setvar.


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