1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-18 09:13:28 +00:00

test command for cli

This commit is contained in:
Kyle Spearrin
2019-03-16 00:45:17 -04:00
parent 183b54f9b8
commit 46827cdaa0
8 changed files with 181 additions and 61 deletions

View File

@@ -4,6 +4,7 @@ import * as program from 'commander';
import { Main } from './bwdc';
import { ConfigCommand } from './commands/config.command';
import { TestCommand } from './commands/test.command';
import { UpdateCommand } from 'jslib/cli/commands/update.command';
@@ -57,10 +58,30 @@ export class Program {
program.on('--help', () => {
writeLn('\n Examples:');
writeLn('');
writeLn(' bwdc login');
writeLn(' bwdc test');
writeLn(' bwdc config server bitwarden.com');
writeLn(' bwdc update');
writeLn('', true);
});
program
.command('test')
.description('Test a simulated sync.')
.option('-l, --last', 'Since the last successful sync.')
.on('--help', () => {
writeLn('\n Examples:');
writeLn('');
writeLn(' bwdc test');
writeLn(' bwdc test --last');
writeLn('', true);
})
.action(async (cmd) => {
await this.exitIfNotAuthed();
const command = new TestCommand(this.main.syncService, this.main.i18nService);
const response = await command.run(cmd);
this.processResponse(response);
});
program
.command('config <setting> <value>')
.description('Configure CLI settings.')
@@ -187,14 +208,6 @@ export class Program {
return out.trim() === '' ? null : out;
}
private async exitIfLocked() {
await this.exitIfNotAuthed();
const hasKey = await this.main.cryptoService.hasKey();
if (!hasKey) {
this.processResponse(Response.error('Vault is locked.'), true);
}
}
private async exitIfAuthed() {
const authed = await this.main.userService.isAuthenticated();
if (authed) {