myshell 2.0.0
Loading...
Searching...
No Matches
msh_process.h
1//
2// Created by andrew on 11/8/23.
3//
4
5#ifndef MYSHELL_MSH_PROCESS_H
6#define MYSHELL_MSH_PROCESS_H
7
8#include <map>
9#include <sstream>
10#include <string>
11#include <vector>
12
13using status_t = enum class status {
14 RUNNING,
15 STOPPED,
16 DONE
17};
18
24struct process {
25 status_t status = status::RUNNING;
26 int flags = 0;
27 std::string command;
28
29 process(int flags, const std::vector<std::string>& args) : flags(flags) {
30 std::stringstream ss;
31 for (auto const& arg: args) {
32 ss << arg << " ";
33 }
34 this->command = ss.str();
35 }
36
37 process() = default;
38
44 [[nodiscard]] std::string get_status() const {
45 switch (status) {
46 using enum status_t;
47 case RUNNING:
48 return "Running";
49 case STOPPED:
50 return "Stopped";
51 case DONE:
52 return "Done";
53 default:
54 return "Unknown";
55 }
56 }
57};
58
59
60#endif //MYSHELL_MSH_PROCESS_H
Top-level command structure.
Definition msh_command.h:48
Information about an internal process.
Definition msh_process.h:24
std::string get_status() const
Returns the status of the process as a string.
Definition msh_process.h:44