mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
cli server: add OpenExternalCommandPipeArgs
This commit is contained in:
@@ -15,7 +15,7 @@ import { ILogService } from 'vs/platform/log/common/log';
|
||||
export interface OpenCommandPipeArgs {
|
||||
type: 'open';
|
||||
fileURIs?: string[];
|
||||
folderURIs: string[];
|
||||
folderURIs?: string[];
|
||||
forceNewWindow?: boolean;
|
||||
diffMode?: boolean;
|
||||
addMode?: boolean;
|
||||
@@ -24,6 +24,11 @@ export interface OpenCommandPipeArgs {
|
||||
waitMarkerFilePath?: string;
|
||||
}
|
||||
|
||||
export interface OpenExternalCommandPipeArgs {
|
||||
type: 'openExternal';
|
||||
uris: string[];
|
||||
}
|
||||
|
||||
export interface StatusPipeArgs {
|
||||
type: 'status';
|
||||
}
|
||||
@@ -34,6 +39,8 @@ export interface RunCommandPipeArgs {
|
||||
args: any[];
|
||||
}
|
||||
|
||||
export type PipeCommand = OpenCommandPipeArgs | StatusPipeArgs | RunCommandPipeArgs | OpenExternalCommandPipeArgs;
|
||||
|
||||
export interface ICommandsExecuter {
|
||||
executeCommand<T>(id: string, ...args: any[]): Promise<T>;
|
||||
}
|
||||
@@ -73,11 +80,14 @@ export class CLIServerBase {
|
||||
req.setEncoding('utf8');
|
||||
req.on('data', (d: string) => chunks.push(d));
|
||||
req.on('end', () => {
|
||||
const data: OpenCommandPipeArgs | StatusPipeArgs | RunCommandPipeArgs | any = JSON.parse(chunks.join(''));
|
||||
const data: PipeCommand | any = JSON.parse(chunks.join(''));
|
||||
switch (data.type) {
|
||||
case 'open':
|
||||
this.open(data, res);
|
||||
break;
|
||||
case 'openExternal':
|
||||
this.openExternal(data, res);
|
||||
break;
|
||||
case 'status':
|
||||
this.getStatus(data, res);
|
||||
break;
|
||||
@@ -133,6 +143,14 @@ export class CLIServerBase {
|
||||
res.end();
|
||||
}
|
||||
|
||||
private openExternal(data: OpenExternalCommandPipeArgs, res: http.ServerResponse) {
|
||||
for (const uri of data.uris) {
|
||||
this._commands.executeCommand('_workbench.open', URI.parse(uri));
|
||||
}
|
||||
res.writeHead(200);
|
||||
res.end();
|
||||
}
|
||||
|
||||
private async getStatus(data: StatusPipeArgs, res: http.ServerResponse) {
|
||||
try {
|
||||
const status = await this._commands.executeCommand('_issues.getSystemStatus');
|
||||
|
||||
Reference in New Issue
Block a user