Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
process.h
1#ifndef SOURCEMETA_CORE_PROCESS_H_
2#define SOURCEMETA_CORE_PROCESS_H_
3
4#ifndef SOURCEMETA_CORE_PROCESS_EXPORT
5#include <sourcemeta/core/process_export.h>
6#endif
7
8// NOLINTBEGIN(misc-include-cleaner)
9#include <sourcemeta/core/process_error.h>
10// NOLINTEND(misc-include-cleaner)
11
12#include <filesystem> // std::filesystem
13#include <initializer_list> // std::initializer_list
14#include <map> // std::map
15#include <optional> // std::optional
16#include <span> // std::span
17#include <string> // std::string
18#include <string_view> // std::string_view
19
28
29namespace sourcemeta::core {
30
39 std::filesystem::path directory{std::filesystem::current_path()};
44 std::optional<std::map<std::string_view, std::string_view>> environment{
45 std::nullopt};
46
48 std::string_view standard_input{};
49};
50
62SOURCEMETA_CORE_PROCESS_EXPORT
63auto spawn(const std::string &program,
64 std::initializer_list<std::string_view> arguments,
65 const ProcessInput &input = {}) -> int;
66
82SOURCEMETA_CORE_PROCESS_EXPORT
83auto spawn(const std::string &program,
84 std::span<const std::string_view> arguments,
85 const ProcessInput &input = {}) -> int;
86
92 std::optional<int> exit_code{std::nullopt};
94 std::string standard_output{};
96 std::string standard_error{};
97};
98
112SOURCEMETA_CORE_PROCESS_EXPORT
113auto spawn_and_capture(const std::string &program,
114 std::initializer_list<std::string_view> arguments,
115 const ProcessInput &input = {}) -> ProcessOutput;
116
133SOURCEMETA_CORE_PROCESS_EXPORT
134auto spawn_and_capture(const std::string &program,
135 std::span<const std::string_view> arguments,
136 const ProcessInput &input = {}) -> ProcessOutput;
137
138} // namespace sourcemeta::core
139
140#endif
std::optional< int > exit_code
Definition process.h:92
std::string standard_error
Everything the program wrote to its standard error.
Definition process.h:96
std::string_view standard_input
Definition process.h:48
std::optional< std::map< std::string_view, std::string_view > > environment
Definition process.h:44
std::filesystem::path directory
Definition process.h:39
std::string standard_output
Everything the program wrote to its standard output.
Definition process.h:94
SOURCEMETA_CORE_PROCESS_EXPORT auto spawn_and_capture(const std::string &program, std::initializer_list< std::string_view > arguments, const ProcessInput &input={}) -> ProcessOutput
SOURCEMETA_CORE_PROCESS_EXPORT auto spawn(const std::string &program, std::initializer_list< std::string_view > arguments, const ProcessInput &input={}) -> int
Definition process.h:36
Definition process.h:89