forked from devonfw/IDEasy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessResult.java
More file actions
116 lines (94 loc) · 3.45 KB
/
ProcessResult.java
File metadata and controls
116 lines (94 loc) · 3.45 KB
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
116
package com.devonfw.tools.ide.process;
import java.util.List;
import com.devonfw.tools.ide.cli.CliProcessException;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.log.IdeLogLevel;
import com.devonfw.tools.ide.log.IdeSubLogger;
/**
* Result of a {@link Process} execution.
*
* @see ProcessContext#run()
*/
public interface ProcessResult {
/** Return code for success. */
int SUCCESS = 0;
/** Return code if IDE_HOME is required but not found. */
int NO_IDE_HOME = 2;
/** Return code if IDE_ROOT is required but not found. */
int NO_IDE_ROOT = 3;
/** Return code if tool was requested that is not installed. */
int TOOL_NOT_INSTALLED = 4;
/** Return code to exit if condition not met */
int EXIT = 17;
/**
* Return code to abort gracefully.
*
* @see com.devonfw.tools.ide.cli.CliAbortException
*/
int ABORT = 22;
/**
* Return code if {@link com.devonfw.tools.ide.context.IdeContext#isOffline() offline} but network is required for requested operation.
*
* @see com.devonfw.tools.ide.cli.CliOfflineException
*/
int OFFLINE = 23;
/**
* @return the filename of the executable that was run (e.g. "git").
* @see #getCommand()
*/
String getExecutable();
/**
* @return the full command that was executed (e.g. "git rev-parse HEAD").
*/
String getCommand();
/**
* @return the exit code. Will be {@link #SUCCESS} on successful completion of the {@link Process}.
*/
int getExitCode();
/**
* @return {@code true} if the {@link #getExitCode() exit code} indicates {@link #SUCCESS}, {@code false} otherwise (an error occurred).
*/
default boolean isSuccessful() {
return getExitCode() == SUCCESS;
}
/**
* @param logger the {@link IdeSubLogger logger} to use.
* @return the first captured standard out. Will be {@code null} if not captured but redirected.
* @throws IllegalStateException if more than one output was captured and the {@link IdeSubLogger logger} was null.
*/
String getSingleOutput(IdeSubLogger logger) throws IllegalStateException;
/**
* @return the {@link List} with the lines captured on standard out. Will be {@code null} if not captured but redirected.
*/
List<String> getOut();
/**
* @return the {@link List} with the lines captured on standard error. Will be {@code null} if not captured but redirected.
*/
List<String> getErr();
/**
* @return the {@link List} with {@link OutputMessage} that captured on standard out and standard error lines. Will be {@code null} if not captured but
* redirected.
*/
List<OutputMessage> getOutputMessages();
/**
* Logs output and error messages on the provided log level.
*
* @param level the {@link IdeLogLevel} to use e.g. IdeLogLevel.ERROR.
* @param context the {@link IdeContext} to use.
*/
void log(IdeLogLevel level, IdeContext context);
/**
* Logs output and error messages on the provided log level.
*
* @param outLevel the {@link IdeLogLevel} to use for {@link #getOut()}.
* @param context the {@link IdeContext} to use.
* @param errorLevel the {@link IdeLogLevel} to use for {@link #getErr()}.
*/
void log(IdeLogLevel outLevel, IdeContext context, IdeLogLevel errorLevel);
/**
* Throws a {@link CliProcessException} if not {@link #isSuccessful() successful} and otherwise does nothing.
*
* @throws CliProcessException if not {@link #isSuccessful() successful}.
*/
void failOnError() throws CliProcessException;
}