-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandExecutor.hpp
41 lines (31 loc) · 973 Bytes
/
CommandExecutor.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// CommandExecutor.hpp
// ncc
//
// Created by yuki on 2022/04/21.
//
#ifndef CommandExecutor_hpp
#define CommandExecutor_hpp
#include <memory>
#include <string>
#include <vector>
#include <sstream>
#include <cstdio>
#include <array>
#include "CommandResult.hpp"
#include "CommandError.hpp"
using namespace std;
class CommandExecutor {
public:
bool disable_stdout;
static auto shared() -> shared_ptr<CommandExecutor>;
static auto silent() -> shared_ptr<CommandExecutor>;
CommandExecutor(bool _disable_stdout) : disable_stdout(_disable_stdout) {
if (!system(nullptr)) throw CommandError::notAvailable();
};
auto execute(const string command, const vector<string> arguments) const -> shared_ptr<CommandResult>;
private:
auto build_commandline(const string command, const vector<string> arguments) const -> string;
auto read_pipe(const shared_ptr<FILE> pipe) const -> string;
};
#endif /* CommandExecutor_hpp */