debt - remove unused node dialog service
parent
2dd7693127
commit
750ed368d2
|
@ -348,7 +348,6 @@
|
|||
"./vs/platform/diagnostics/electron-main/diagnosticsService.ts",
|
||||
"./vs/platform/dialogs/common/dialogs.ts",
|
||||
"./vs/platform/dialogs/node/dialogIpc.ts",
|
||||
"./vs/platform/dialogs/node/dialogService.ts",
|
||||
"./vs/platform/download/common/download.ts",
|
||||
"./vs/platform/download/node/downloadIpc.ts",
|
||||
"./vs/platform/download/node/downloadService.ts",
|
||||
|
|
|
@ -36,8 +36,6 @@ import { IDiagnosticsService, DiagnosticsService } from 'vs/platform/diagnostics
|
|||
import { BufferLogService } from 'vs/platform/log/common/bufferLog';
|
||||
import { uploadLogs } from 'vs/code/electron-main/logUploader';
|
||||
import { setUnexpectedErrorHandler } from 'vs/base/common/errors';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { CommandLineDialogService } from 'vs/platform/dialogs/node/dialogService';
|
||||
import { createWaitMarkerFile } from 'vs/code/node/wait';
|
||||
|
||||
class ExpectedError extends Error {
|
||||
|
@ -310,7 +308,6 @@ function createServices(args: ParsedArgs, bufferLogService: BufferLogService): I
|
|||
services.set(IStateService, new SyncDescriptor(StateService));
|
||||
services.set(IConfigurationService, new SyncDescriptor(ConfigurationService));
|
||||
services.set(IRequestService, new SyncDescriptor(RequestService));
|
||||
services.set(IDialogService, new SyncDescriptor(CommandLineDialogService));
|
||||
services.set(IDiagnosticsService, new SyncDescriptor(DiagnosticsService));
|
||||
|
||||
return new InstantiationService(services, true);
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as readline from 'readline';
|
||||
import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { localize } from 'vs/nls';
|
||||
import { canceled } from 'vs/base/common/errors';
|
||||
|
||||
export class CommandLineDialogService implements IDialogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
show(severity: Severity, message: string, options: string[]): Promise<number> {
|
||||
const promise = new Promise<number>((c, e) => {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
terminal: true
|
||||
});
|
||||
rl.prompt();
|
||||
rl.write(this.toQuestion(message, options));
|
||||
|
||||
rl.prompt();
|
||||
|
||||
rl.once('line', (answer) => {
|
||||
rl.close();
|
||||
c(this.toOption(answer, options));
|
||||
});
|
||||
rl.once('SIGINT', () => {
|
||||
rl.close();
|
||||
e(canceled());
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
private toQuestion(message: string, options: string[]): string {
|
||||
return options.reduce((previousValue: string, currentValue: string, currentIndex: number) => {
|
||||
return previousValue + currentValue + '(' + currentIndex + ')' + (currentIndex < options.length - 1 ? ' | ' : '\n');
|
||||
}, message + ' ');
|
||||
}
|
||||
|
||||
private toOption(answer: string, options: string[]): number {
|
||||
const value = parseInt(answer);
|
||||
if (!isNaN(value)) {
|
||||
return value;
|
||||
}
|
||||
answer = answer.toLocaleLowerCase();
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
if (options[i].toLocaleLowerCase() === answer) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
|
||||
return this.show(Severity.Info, confirmation.message, [confirmation.primaryButton || localize('ok', "Ok"), confirmation.secondaryButton || localize('cancel', "Cancel")]).then(index => {
|
||||
return {
|
||||
confirmed: index === 0
|
||||
} as IConfirmationResult;
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue