diff --git a/src/program.ts b/src/program.ts index 03a75e62df4..1cb093b0421 100644 --- a/src/program.ts +++ b/src/program.ts @@ -119,11 +119,13 @@ export class Program extends BaseProgram { writeLn('', true); }) .action(async (email: string, password: string, cmd: program.Command) => { - await this.exitIfAuthed(); - const command = new LoginCommand(this.main.authService, this.main.apiService, - this.main.cryptoFunctionService, this.main.syncService, this.main.i18nService); - const response = await command.run(email, password, cmd); - this.processResponse(response); + if (!cmd.check) { + await this.exitIfAuthed(); + const command = new LoginCommand(this.main.authService, this.main.apiService, + this.main.cryptoFunctionService, this.main.syncService, this.main.i18nService); + const response = await command.run(email, password, cmd); + this.processResponse(response); + } }); program @@ -176,12 +178,22 @@ export class Program extends BaseProgram { writeLn(' bw unlock myPassword321 --raw'); writeLn('', true); }) + .option('--check', 'Check vault status.', async () => { + const locked = await this.main.lockService.isLocked(); + if (!locked) { + const res = new MessageResponse('Vault is unlocked!', null); + this.processResponse(Response.success(res), true); + } + this.processResponse(Response.error('Vault is locked.'), true); + }) .action(async (password, cmd) => { - await this.exitIfNotAuthed(); - const command = new UnlockCommand(this.main.cryptoService, this.main.userService, - this.main.cryptoFunctionService); - const response = await command.run(password, cmd); - this.processResponse(response); + if (!cmd.check) { + await this.exitIfNotAuthed(); + const command = new UnlockCommand(this.main.cryptoService, this.main.userService, + this.main.cryptoFunctionService); + const response = await command.run(password, cmd); + this.processResponse(response); + } }); program