@@ -7,30 +7,49 @@ declare module 'vscode' {
7
7
8
8
// https://github.com/microsoft/vscode/issues/145234
9
9
10
- // TODO: Add missing docs
11
- // TODO: Review and polish up all docs
10
+ /**
11
+ * A command that was executed in a terminal.
12
+ */
12
13
export interface TerminalShellExecution {
13
14
/**
14
- * The full command line that was executed, including both the command and arguments. The
15
- * {@link TerminalShellExecutionCommandLineConfidence confidence} of this value depends on
16
- * the specific shell's shell integration implementation. This value may become more
17
- * accurate after {@link onDidEndTerminalShellExecution} is fired.
15
+ * The command line that was executed. The {@link TerminalShellExecutionCommandLineConfidence confidence}
16
+ * of this value depends on the specific shell's shell integration implementation. This
17
+ * value may become more accurate after {@link window.onDidEndTerminalShellExecution} is
18
+ * fired.
19
+ *
20
+ * @example
21
+ * // Log the details of the command line on start and end
22
+ * window.onDidStartTerminalShellExecution(event => {
23
+ * const commandLine = event.execution.commandLine;
24
+ * console.log(`Command started\n${summarizeCommandLine(commandLine)}`);
25
+ * });
26
+ * window.onDidEndTerminalShellExecution(event => {
27
+ * const commandLine = event.execution.commandLine;
28
+ * console.log(`Command ended\n${summarizeCommandLine(commandLine)}`);
29
+ * });
30
+ * function summarizeCommandLine(commandLine: TerminalShellExecutionCommandLine) {
31
+ * return [
32
+ * ` Command line: ${command.ommandLine.value}`,
33
+ * ` Confidence: ${command.ommandLine.confidence}`,
34
+ * ` Trusted: ${command.ommandLine.isTrusted}
35
+ * ].join('\n');
36
+ * }
18
37
*/
19
38
readonly commandLine : TerminalShellExecutionCommandLine ;
20
39
21
40
/**
22
41
* The working directory that was reported by the shell when this command executed. This
23
- * will be a {@link Uri} if the path reported by the shell can reliably be mapped to the
24
- * connected machine. This requires the shell integration to support working directory
25
- * reporting.
42
+ * {@link Uri} may represent a file on another machine (eg. ssh into another machine). This
43
+ * requires the shell integration to support working directory reporting.
26
44
*/
27
45
readonly cwd : Uri | undefined ;
28
46
29
47
/**
30
48
* Creates a stream of raw data (including escape sequences) that is written to the
31
- * terminal. This will only include data that was written after `stream` was called for the
32
- * first time, ie. you must call `dataStream` immediately after the command is executed via
33
- * {@link executeCommand} or {@link onDidStartTerminalShellExecution} to not miss any data.
49
+ * terminal. This will only include data that was written after `readData` was called for
50
+ * the first time, ie. you must call `readData` immediately after the command is executed
51
+ * via {@link TerminalShellIntegration.executeCommand} or
52
+ * {@link window.onDidStartTerminalShellExecution} to not miss any data.
34
53
*
35
54
* @example
36
55
* // Log all data written to the terminal for a command
@@ -57,11 +76,12 @@ declare module 'vscode' {
57
76
/**
58
77
* Whether the command line value came from a trusted source and is therefore safe to
59
78
* execute without user additional confirmation, such as a notification that asks "Do you
60
- * want to execute (command)?".
79
+ * want to execute (command)?". This verification is likely only needed if you are going to
80
+ * execute the command again.
61
81
*
62
- * This is false when the command line was reported explicitly by the shell integration
63
- * script (ie. {@link TerminalShellExecutionCommandLineConfidence.High high confidence}),
64
- * but did not include a nonce for verification.
82
+ * This is `true` only when the command line was reported explicitly by the shell
83
+ * integration script (ie. {@link TerminalShellExecutionCommandLineConfidence.High high confidence})
84
+ * and it used a nonce for verification.
65
85
*/
66
86
isTrusted : boolean ;
67
87
@@ -97,15 +117,16 @@ declare module 'vscode' {
97
117
98
118
/**
99
119
* The command line value confidence is high. This means that the value was explicitly sent
100
- * from the shell integration script.
120
+ * from the shell integration script or the command was executed via the
121
+ * {@link TerminalShellIntegration.executeCommand} API.
101
122
*/
102
123
High = 2
103
124
}
104
125
105
126
export interface Terminal {
106
127
/**
107
128
* An object that contains [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration)-powered
108
- * features for the terminal. This will always be undefined immediately after the terminal
129
+ * features for the terminal. This will always be ` undefined` immediately after the terminal
109
130
* is created. Listen to {@link window.onDidActivateTerminalShellIntegration} to be notified
110
131
* when shell integration is activated for a terminal.
111
132
*
@@ -116,10 +137,14 @@ declare module 'vscode' {
116
137
readonly shellIntegration : TerminalShellIntegration | undefined ;
117
138
}
118
139
140
+ /**
141
+ * [Shell integration](https://code.visualstudio.com/docs/terminal/shell-integration)-powered capabilities owned by a terminal.
142
+ */
119
143
export interface TerminalShellIntegration {
120
144
/**
121
- * The current working directory of the terminal. This will be a {@link Uri} if the path
122
- * reported by the shell can reliably be mapped to the connected machine.
145
+ * The current working directory of the terminal. This {@link Uri} may represent a file on
146
+ * another machine (eg. ssh into another machine). This requires the shell integration to
147
+ * support working directory reporting.
123
148
*/
124
149
readonly cwd : Uri | undefined ;
125
150
0 commit comments