diff --git a/src/commands/delete.command.ts b/src/commands/delete.command.ts index d0ee7e43bc..ea2a1600f5 100644 --- a/src/commands/delete.command.ts +++ b/src/commands/delete.command.ts @@ -39,10 +39,10 @@ export class DeleteCommand { } try { - if (cmd.trash) { - await this.cipherService.softDeleteWithServer(id); - } else { + if (cmd.permanent) { await this.cipherService.deleteWithServer(id); + } else { + await this.cipherService.softDeleteWithServer(id); } return Response.success(); } catch (e) { diff --git a/src/commands/list.command.ts b/src/commands/list.command.ts index 6d20df62be..b28f573c93 100644 --- a/src/commands/list.command.ts +++ b/src/commands/list.command.ts @@ -58,6 +58,7 @@ export class ListCommand { private async listCiphers(cmd: program.Command) { let ciphers: CipherView[]; + cmd.trash = cmd.trash || false; if (cmd.url != null && cmd.url.trim() !== '') { ciphers = await this.cipherService.getAllDecryptedForUrl(cmd.url); } else { @@ -66,7 +67,7 @@ export class ListCommand { if (cmd.folderid != null || cmd.collectionid != null || cmd.organizationid != null) { ciphers = ciphers.filter((c) => { - if (cmd.trash && !c.isDeleted) { + if (cmd.trash !== c.isDeleted) { return false; } if (cmd.folderid != null) { @@ -104,11 +105,11 @@ export class ListCommand { return false; }); } else if (cmd.search == null || cmd.search.trim() === '') { - ciphers = ciphers.filter((c) => (cmd.trash || false) === c.isDeleted); + ciphers = ciphers.filter((c) => cmd.trash === c.isDeleted); } if (cmd.search != null && cmd.search.trim() !== '') { - ciphers = this.searchService.searchCiphersBasic(ciphers, cmd.search, cmd.trash || false); + ciphers = this.searchService.searchCiphersBasic(ciphers, cmd.search, cmd.trash); } const res = new ListResponse(ciphers.map((o) => new CipherResponse(o))); diff --git a/src/program.ts b/src/program.ts index 212267a034..6f8a40c557 100644 --- a/src/program.ts +++ b/src/program.ts @@ -396,7 +396,7 @@ export class Program extends BaseProgram { .command('delete ') .option('--itemid ', 'Attachment\'s item id.') .option('--organizationid ', 'Organization id for an organization object.') - .option('-t, --trash', 'Places the item in the trash instead of permanently deleting it (item only).') + .option('-p, --permanent', 'Permanently deletes the item instead of soft-deleting it (item only).') .description('Delete an object from the vault.') .on('--help', () => { writeLn('\n Objects:'); @@ -413,7 +413,7 @@ export class Program extends BaseProgram { writeLn(' Examples:'); writeLn(''); writeLn(' bw delete item 7063feab-4b10-472e-b64c-785e2b870b92'); - writeLn(' bw delete item 89c21cd2-fab0-4f69-8c6e-ab8a0168f69a --trash'); + writeLn(' bw delete item 89c21cd2-fab0-4f69-8c6e-ab8a0168f69a --permanent'); writeLn(' bw delete folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02'); writeLn(' bw delete attachment b857igwl1dzrs2 --itemid 310d5ffd-e9a2-4451-af87-ea054dce0f78'); writeLn('', true);