status from ext host cli

This commit is contained in:
Martin Aeschlimann
2019-03-25 17:39:06 +01:00
parent 9eb5669101
commit 0f45c39d97
6 changed files with 43 additions and 2 deletions

View File

@@ -22,6 +22,10 @@ export interface OpenCommandPipeArgs {
waitMarkerFilePath?: string;
}
export interface StatusPipeArgs {
type: 'status';
}
export class CLIServer {
private _server: http.Server;
@@ -68,11 +72,14 @@ export class CLIServer {
req.setEncoding('utf8');
req.on('data', (d: string) => chunks.push(d));
req.on('end', () => {
const data: OpenCommandPipeArgs | any = JSON.parse(chunks.join(''));
const data: OpenCommandPipeArgs | StatusPipeArgs | any = JSON.parse(chunks.join(''));
switch (data.type) {
case 'open':
this.open(data, res);
break;
case 'status':
this.getStatus(data, res);
break;
default:
res.writeHead(404);
res.write(`Unkown message type: ${data.type}`, err => {
@@ -103,6 +110,23 @@ export class CLIServer {
res.end();
}
private async getStatus(data: StatusPipeArgs, res: http.ServerResponse) {
try {
const status = await this._commands.executeCommand('_issues.getSystemStatus');
res.writeHead(200);
res.write(status);
res.end();
} catch (err) {
res.writeHead(500);
res.write(String(err), err => {
if (err) {
console.error(err);
}
});
res.end();
}
}
dispose(): void {
this._server.close();