Explicit remote CLI commands (#121212)

This commit is contained in:
Martin Aeschlimann
2021-04-08 16:59:16 +02:00
committed by Alexandru Dima
parent ceda963326
commit c826e9aabd
4 changed files with 37 additions and 51 deletions

View File

@@ -33,12 +33,6 @@ export interface StatusPipeArgs {
type: 'status';
}
export interface RunCommandPipeArgs {
type: 'command';
command: string;
args: any[];
}
export interface ExtensionManagementPipeArgs {
type: 'extensionManagement';
list?: { showVersions?: boolean, category?: string; };
@@ -47,7 +41,7 @@ export interface ExtensionManagementPipeArgs {
force?: boolean;
}
export type PipeCommand = OpenCommandPipeArgs | StatusPipeArgs | RunCommandPipeArgs | OpenExternalCommandPipeArgs | ExtensionManagementPipeArgs;
export type PipeCommand = OpenCommandPipeArgs | StatusPipeArgs | OpenExternalCommandPipeArgs | ExtensionManagementPipeArgs;
export interface ICommandsExecuter {
executeCommand<T>(id: string, ...args: any[]): Promise<T>;
@@ -99,10 +93,6 @@ export class CLIServerBase {
case 'status':
this.getStatus(data, res);
break;
case 'command':
this.runCommand(data, res)
.catch(this.logService.error);
break;
case 'extensionManagement':
this.manageExtensions(data, res)
.catch(this.logService.error);
@@ -149,7 +139,7 @@ export class CLIServerBase {
const waitMarkerFileURI = waitMarkerFilePath ? URI.file(waitMarkerFilePath) : undefined;
const preferNewWindow = !forceReuseWindow && !waitMarkerFileURI && !addMode;
const windowOpenArgs: IOpenWindowOptions = { forceNewWindow, diffMode, addMode, gotoLineMode, forceReuseWindow, preferNewWindow, waitMarkerFileURI };
this._commands.executeCommand('_files.windowOpen', urisToOpen, windowOpenArgs);
this._commands.executeCommand('_remoteCLI.windowOpen', urisToOpen, windowOpenArgs);
}
res.writeHead(200);
res.end();
@@ -190,7 +180,7 @@ export class CLIServerBase {
private async getStatus(data: StatusPipeArgs, res: http.ServerResponse) {
try {
const status = await this._commands.executeCommand('_issues.getSystemStatus');
const status = await this._commands.executeCommand('_remoteCLI.getSystemStatus');
res.writeHead(200);
res.write(status);
res.end();
@@ -205,28 +195,6 @@ export class CLIServerBase {
}
}
private async runCommand(data: RunCommandPipeArgs, res: http.ServerResponse) {
try {
const { command, args } = data;
const result = await this._commands.executeCommand(command, ...args);
res.writeHead(200);
res.write(JSON.stringify(result), err => {
if (err) {
this.logService.error(err);
}
});
res.end();
} catch (err) {
res.writeHead(500);
res.write(String(err), err => {
if (err) {
this.logService.error(err);
}
});
res.end();
}
}
dispose(): void {
this._server.close();