server cli: use deprecated option

This commit is contained in:
Martin Aeschlimann 2021-11-29 21:38:40 +01:00
parent 0685366bdf
commit 6191026e27
No known key found for this signature in database
GPG key ID: 2609A01E695523E3
5 changed files with 14 additions and 13 deletions

View file

@ -155,11 +155,13 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
export interface ErrorReporter {
onUnknownOption(id: string): void;
onMultipleValues(id: string, usedValue: string): void;
onDeprecatedOption(deprecatedId: string, currentId: string): void;
}
const ignoringReporter: ErrorReporter = {
onUnknownOption: () => { },
onMultipleValues: () => { }
onMultipleValues: () => { },
onDeprecatedOption: () => { }
};
export function parseArgs<T>(args: string[], options: OptionDescriptions<T>, errorReporter: ErrorReporter = ignoringReporter): T {
@ -205,6 +207,7 @@ export function parseArgs<T>(args: string[], options: OptionDescriptions<T>, err
if (o.deprecates && remainingArgs.hasOwnProperty(o.deprecates)) {
if (!val) {
val = remainingArgs[o.deprecates];
errorReporter.onDeprecatedOption(o.deprecates, optionId);
}
delete remainingArgs[o.deprecates];
}

View file

@ -17,6 +17,9 @@ function parseAndValidate(cmdLineArgs: string[], reportWarnings: boolean): Nativ
},
onMultipleValues: (id, val) => {
console.warn(localize('multipleValues', "Option '{0}' is defined more than once. Using value '{1}.'", id, val));
},
onDeprecatedOption: (deprecatedOption: string, actualOption: string) => {
console.warn(localize('deprecatedArgument', "Option '{0}' is deprecated, please use '{1}' instead", deprecatedOption, actualOption));
}
};

View file

@ -25,6 +25,10 @@ const errorReporter: ErrorReporter = {
onUnknownOption: (id: string) => {
console.error(`Ignoring option ${id}: not supported for server.`);
},
onDeprecatedOption: (deprecatedOption: string, actualOption: string) => {
console.warn(`Option '${deprecatedOption}' is deprecated, please use '${actualOption}' instead`);
}
};

View file

@ -918,10 +918,6 @@ export class RemoteExtensionHostAgentServer extends Disposable {
}
function parseConnectionToken(args: ServerParsedArgs): { connectionToken: string; connectionTokenIsMandatory: boolean; } {
if (args['connectionToken']) {
console.warn(`The argument '--connectionToken' is deprecated, please use '--connection-token' instead`);
}
if (args['connection-secret']) {
if (args['connection-token']) {
console.warn(`Please do not use the argument '--connection-token' at the same time as '--connection-secret'.`);
@ -935,7 +931,7 @@ function parseConnectionToken(args: ServerParsedArgs): { connectionToken: string
}
return { connectionToken: rawConnectionToken, connectionTokenIsMandatory: true };
} else {
return { connectionToken: args['connection-token'] || args['connectionToken'] || generateUuid(), connectionTokenIsMandatory: false };
return { connectionToken: args['connection-token'] || generateUuid(), connectionTokenIsMandatory: false };
}
}

View file

@ -12,9 +12,8 @@ import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/envi
export const serverOptions: OptionDescriptions<ServerParsedArgs> = {
'port': { type: 'string' },
'pick-port': { type: 'string' },
'connectionToken': { type: 'string' }, // deprecated in favor of `--connection-token`
'connection-token': { type: 'string', description: nls.localize('connection-token', "A secret that must be included by the web client with all requests.") },
'connection-secret': { type: 'string', description: nls.localize('connection-secret', "Path to file that contains the connection token. This will require that all incoming connections know the secret.") },
'connection-token': { type: 'string', cat: 'o', deprecates: 'connectionToken', description: nls.localize('connection-token', "A secret that must be included by the web client with all requests.") },
'connection-secret': { type: 'string', cat: 'o', description: nls.localize('connection-secret', "Path to file that contains the connection token. This will require that all incoming connections know the secret.") },
'host': { type: 'string' },
'socket-path': { type: 'string' },
'driver': { type: 'string' },
@ -65,10 +64,6 @@ export const serverOptions: OptionDescriptions<ServerParsedArgs> = {
export interface ServerParsedArgs {
port?: string;
'pick-port'?: string;
/**
* @deprecated use `connection-token` instead
*/
connectionToken?: string;
/**
* A secret token that must be provided by the web client with all requests.
* Use only `[0-9A-Za-z\-]`.