1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-14 07:13:25 +00:00

clear cache command

This commit is contained in:
Kyle Spearrin
2019-03-18 13:04:23 -04:00
parent 93cedec32c
commit bd072b727c
2 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
import * as program from 'commander';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { ConfigurationService } from '../services/configuration.service';
import { Response } from 'jslib/cli/models/response';
import { MessageResponse } from 'jslib/cli/models/response/messageResponse';
export class ClearCacheCommand {
constructor(private configurationService: ConfigurationService, private i18nService: I18nService) { }
async run(cmd: program.Command): Promise<Response> {
try {
await this.configurationService.clearStatefulSettings(true);
const res = new MessageResponse(this.i18nService.t('syncCacheCleared'), null);
return Response.success(res);
} catch (e) {
return Response.error(e);
}
}
}

View File

@@ -3,6 +3,7 @@ import * as program from 'commander';
import { Main } from './bwdc'; import { Main } from './bwdc';
import { ClearCacheCommand } from './commands/clearCache.command';
import { ConfigCommand } from './commands/config.command'; import { ConfigCommand } from './commands/config.command';
import { SyncCommand } from './commands/sync.command'; import { SyncCommand } from './commands/sync.command';
import { TestCommand } from './commands/test.command'; import { TestCommand } from './commands/test.command';
@@ -144,7 +145,7 @@ export class Program extends BaseProgram {
program program
.command('config <setting> <value>') .command('config <setting> <value>')
.description('Configure CLI settings.') .description('Configure settings.')
.on('--help', () => { .on('--help', () => {
writeLn('\n Settings:'); writeLn('\n Settings:');
writeLn(''); writeLn('');
@@ -162,6 +163,21 @@ export class Program extends BaseProgram {
this.processResponse(response); this.processResponse(response);
}); });
program
.command('clear-cache')
.description('Clear the sync cache.')
.on('--help', () => {
writeLn('\n Examples:');
writeLn('');
writeLn(' bwdc clear-cache');
writeLn('', true);
})
.action(async (cmd) => {
const command = new ClearCacheCommand(this.main.configurationService, this.main.i18nService);
const response = await command.run(cmd);
this.processResponse(response);
});
program program
.command('update') .command('update')
.description('Check for updates.') .description('Check for updates.')