mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-02 18:17:46 +01:00
get config value when value not provided
This commit is contained in:
parent
7205b8c189
commit
492bc32aa3
@ -4,6 +4,7 @@ import { EnvironmentService } from 'jslib/abstractions/environment.service';
|
||||
|
||||
import { Response } from 'jslib/cli/models/response';
|
||||
import { MessageResponse } from 'jslib/cli/models/response/messageResponse';
|
||||
import { StringResponse } from 'jslib/cli/models/response/stringResponse';
|
||||
|
||||
export class ConfigCommand {
|
||||
constructor(private environmentService: EnvironmentService) { }
|
||||
@ -12,20 +13,25 @@ export class ConfigCommand {
|
||||
setting = setting.toLowerCase();
|
||||
switch (setting) {
|
||||
case 'server':
|
||||
await this.setServer(value);
|
||||
break;
|
||||
return await this.getOrSetServer(value);
|
||||
default:
|
||||
return Response.badRequest('Unknown setting.');
|
||||
}
|
||||
|
||||
const res = new MessageResponse('Saved setting `' + setting + '`.', null);
|
||||
return Response.success(res);
|
||||
}
|
||||
|
||||
private async setServer(url: string) {
|
||||
private async getOrSetServer(url: string): Promise<Response> {
|
||||
if (url == null || url.trim() === '') {
|
||||
const baseUrl = this.environmentService.baseUrl;
|
||||
const stringRes = new StringResponse(baseUrl == null ? 'https://bitwarden.com' : baseUrl);
|
||||
return Response.success(stringRes);
|
||||
}
|
||||
|
||||
url = (url === 'null' || url === 'bitwarden.com' || url === 'https://bitwarden.com' ? null : url);
|
||||
await this.environmentService.setUrls({
|
||||
base: url,
|
||||
});
|
||||
const res = new MessageResponse('Saved setting `config`.', null);
|
||||
return Response.success(res);
|
||||
}
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ export class Program extends BaseProgram {
|
||||
});
|
||||
|
||||
program
|
||||
.command('config <setting> <value>')
|
||||
.command('config <setting> [value]')
|
||||
.description('Configure CLI settings.')
|
||||
.on('--help', () => {
|
||||
writeLn('\n Settings:');
|
||||
|
Loading…
Reference in New Issue
Block a user