BashSpark
Loading...
Searching...
No Matches
bs::command_test Class Reference

Performs a test. Returns through status code. More...

#include <command_test.h>

Inheritance diagram for bs::command_test:
Collaboration diagram for bs::command_test:

Public Member Functions

 command_test ()
 Constructs command.
 
shell_status run (const std::span< const std::string > &vArgs, shell_session &oSession) const override
 Performs a test.
 
virtual void msg_error_test (std::ostream &oStdErr, shell_status nStatus) const
 Displays the error message for test errors.
 
- Public Member Functions inherited from bs::command
 command (std::string sName)
 Construct a command with a given name.
 
virtual ~command ()=default
 Virtual destructor.
 
std::string get_name () const
 Get the command name (copy).
 
const std::string & get_name_ref () const noexcept
 Get the command name (reference).
 

Detailed Description

Performs a test. Returns through status code.

Syntax: test args Syntax: test args

Capabilities:

  • Operators or: -o, ||
  • Operators and: -a, &&
  • Comparison operators: ==, -eq, >, -gt, <, -lt, >=, -ge, <=, -le Note that comparison operators will apply numeric comparison if both arguments are numbers or <=> on std::string if they aren't.
  • Operator =~: use a =~ b, checks if a matches b. Uses C++ regex, not bash regex.
  • Parentheses: ( ) (and nested parentheses).

Possible outputs:

Member Function Documentation

◆ msg_error_test()

void bs::command_test::msg_error_test ( std::ostream &  oStdErr,
shell_status  nStatus 
) const
virtual

Displays the error message for test errors.

Can be overwritten with custom behaviour.

Parameters
oStdErrError output stream
nStatusStatus code

◆ run()

shell_status bs::command_test::run ( const std::span< const std::string > &  vArgs,
shell_session oSession 
) const
overridevirtual

Performs a test.

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

Implements bs::command.


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