$darkmode
cloe::Command Class Reference

#include <command.hpp>

Inheritance diagram for cloe::Command:
Collaboration diagram for cloe::Command:

Public Types

enum class  Mode { Sync , Async , Detach }
 
enum class  Verbosity { Never , OnError , Always }
 

Public Member Functions

 Command (const std::string &command)
 
 Command (boost::filesystem::path executable, std::initializer_list< std::string > args)
 
boost::filesystem::path executable () const
 
const std::vector< std::string > & args () const
 
std::string command () const
 
Verbosity verbosity () const
 
Command verbosity (Verbosity v) &&
 
void set_verbosity (Verbosity v)
 
Mode mode () const
 
Command mode (Mode m) &&
 
void set_mode (Mode m)
 
Command sync () &&
 
bool is_sync () const
 
Command async () &&
 
bool is_async () const
 
Command detach () &&
 
bool is_detach () const
 
bool ignore_failure () const
 
Command ignore_failure (bool v) &&
 
void set_ignore_failure (bool v)
 
 CONFABLE_SCHEMA (Command)
 
void from_conf (const Conf &c) override
 
- Public Member Functions inherited from fable::Confable
 Confable (const Confable &) noexcept
 
 Confable (Confable &&) noexcept=default
 
Confableoperator= (const Confable &other) noexcept
 
Confableoperator= (Confable &&other) noexcept
 
virtual void reset_schema ()
 
Schemaschema ()
 
const Schemaschema () const
 
virtual void validate_or_throw (const Conf &c) const
 
virtual bool validate (const Conf &c, std::optional< SchemaError > &err) const
 
virtual void to_json (Json &j) const
 
Json to_json () const
 

Additional Inherited Members

- Protected Member Functions inherited from fable::Confable
virtual Schema schema_impl ()
 

Detailed Description

Command describes the execution of a command.

There are two ways a command can normally be executed:

  1. Direct execution (executable + args). A system call is used to directly start the command as a child process passed the specific arguments defined.
  2. Shell execution (command). An available shell is used to run the passed expression.

Shell execution includes the interpretation of all sorts of symbols and may include functions that are only available to the shell itself. For these commands, no validation can occur pre-execution.

Member Enumeration Documentation

◆ Mode

enum cloe::Command::Mode
strong

Execution mode.

Enumerator
Async 

run command and wait for completion

Detach 

run command in background but wait for completion at destruction

◆ Verbosity

Logging verbosity.

Enumerator
OnError 

never log anything

Always 

log combined error when an error occurs

Member Function Documentation

◆ args()

const std::vector<std::string>& cloe::Command::args ( ) const
inline

Return the executable arguments.

◆ command()

std::string cloe::Command::command ( ) const

Return the command as a string.

This does not necessarily have the correct characters escaped so as to be result in the same execution when pasted into a shell.

◆ executable()

boost::filesystem::path cloe::Command::executable ( ) const
inline

Return the executable.

◆ from_conf()

void cloe::Command::from_conf ( const Conf c)
overridevirtual

Deserialize a Confable from a Conf.

Unless you have special needs, it is recommended to implement

Schema schema_impl()

and use the default implementation of this.

Reimplemented from fable::Confable.

Here is the call graph for this function:
Here is the caller graph for this function:

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