#include <fetch.h>
|
typedef std::function< void(Command)> | func_type |
|
Command executes a command in a subshell(shell runs on a forked process).
Sample code:
if (c.getExitcode() == 0) {
std::cout << c.getOutput();
}
static Command exec(const string &cmd)
Definition: fetch.h:273
◆ exec()
static Command Command::exec |
( |
const string & |
cmd | ) |
|
|
inlinestatic |
Executes the specified command.
- Parameters
-
cmd | containing the command to call and its arguments |
- Returns
- Command object for getting the results.
- Exceptions
-
runtime_error | failed to popen(3) |
◆ exec_async() [1/2]
static void Command::exec_async |
( |
const Path & |
cmd, |
|
|
const string & |
arg, |
|
|
const func_type & |
func |
|
) |
| |
|
inlinestatic |
Executes the specified command in a new thread.
- Parameters
-
cmd | containing the command |
arg | arguments |
func | to be performed after cmd is finished |
◆ exec_async() [2/2]
static void Command::exec_async |
( |
const string & |
cmd, |
|
|
const func_type & |
func |
|
) |
| |
|
inlinestatic |
Executes the specified command in a new thread.
- Parameters
-
cmd | containing the command to call and its arguments |
func | to be performed after cmd is finished |
◆ getErrorOutput()
string Command::getErrorOutput |
( |
| ) |
|
|
inline |
- Returns
- get contents written by the command to standard error output
◆ getExceptions()
static vector<runtime_error>& Command::getExceptions |
( |
| ) |
|
|
inlinestatic |
◆ getExitCode()
int Command::getExitCode |
( |
| ) |
|
|
inline |
- Returns
- get the exit code of the command.
◆ getOutput()
string Command::getOutput |
( |
| ) |
|
|
inline |
- Returns
- get contents written by the command to standard output
◆ getOutputLines()
int Command::getOutputLines |
( |
| ) |
|
|
inline |
- Returns
- get the new line counts of the output.
◆ wait()
static void Command::wait |
( |
| ) |
|
|
inlinestatic |
Wait for all threads to be finished.
The documentation for this class was generated from the following files: