-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprocess_result.e
executable file
·115 lines (88 loc) · 2.01 KB
/
process_result.e
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
note
component: "Eiffel Object Modelling Framework"
description: "Result of a process - exit code, stdout, stderr"
keywords: "error, process"
author: "Thomas Beale <[email protected]>"
support: "http://www.openehr.org/issues/browse/AWB"
copyright: "Copyright (c) 2014- openEHR Foundation <http://www.openEHR.org>"
license: "Apache 2.0 License <http://www.apache.org/licenses/LICENSE-2.0.html>"
class PROCESS_RESULT
inherit
ANY
redefine
default_create
end
create
make, default_create
feature -- Definitions
Exit_did_not_run: INTEGER = -1
No_command: STRING = "no_command"
feature -- Initialisation
default_create
do
make (No_command, Void)
end
make (a_cmd_line: STRING; in_directory: detachable STRING)
-- make with exit_code -1 to indicate that no process has run
do
exit_code := Exit_did_not_run
command_line := a_cmd_line
if attached in_directory as att_dir then
directory := att_dir
end
ensure
exit_code = Exit_did_not_run
end
feature -- Access
command_line: STRING
directory: STRING
attribute
create Result.make_empty
end
exit_code: INTEGER
-- return code; 0 = success
stdout: STRING
attribute
create Result.make_empty
end
stderr: STRING
attribute
create Result.make_empty
end
error_output: STRING
-- obtain error output; use `stderr' value if available, but if nothing there
-- use `stdout' value.
do
if not stderr.is_empty then
Result := stderr
else
Result := stdout
end
end
feature -- Status Report
succeeded: BOOLEAN
do
Result := exit_code = 0
end
failed: BOOLEAN
do
Result := exit_code > 0
end
did_not_run: BOOLEAN
do
Result := exit_code = Exit_did_not_run
end
feature -- Modification
set_exit_code (a_code: INTEGER)
do
exit_code := a_code
end
append_stdout (a_str: STRING)
do
stdout.append (a_str)
end
append_stderr (a_str: STRING)
do
stderr.append (a_str)
end
end