MCPcopy Create free account
hub / github.com/bitwarden/clients / deleteCommand

Method deleteCommand

apps/cli/src/vault.program.ts:388–445  ·  view source on GitHub ↗
(useSharedFoldersTerm: boolean)

Source from the content-addressed store, hash-verified

386 }
387
388 private deleteCommand(useSharedFoldersTerm: boolean): Command {
389 const deleteObjects = [
390 "item",
391 "attachment",
392 "folder",
393 "my-folder",
394 "org-collection",
395 "org-shared-folder",
396 ];
397 const shownObjects = this.visibleObjects(deleteObjects, useSharedFoldersTerm);
398 return new Command("delete")
399 .argument("<object>", "Valid objects are: " + shownObjects.join(", "))
400 .argument("<id>", "Object's globally unique `id`.")
401 .description("Delete an object from the vault.")
402 .option("--itemid <itemid>", "Attachment's item id.")
403 .option("--organizationid <organizationid>", "Organization id for an organization object.")
404 .option(
405 "-p, --permanent",
406 "Permanently deletes the item instead of soft-deleting it (item only).",
407 )
408 .on("--help", () => {
409 writeLn("\n Examples:");
410 writeLn("");
411 writeLn(" bw delete item 7063feab-4b10-472e-b64c-785e2b870b92");
412 writeLn(" bw delete item 89c21cd2-fab0-4f69-8c6e-ab8a0168f69a --permanent");
413 writeLn(
414 ` bw delete ${useSharedFoldersTerm ? "my-folder" : "folder"} 5cdfbd80-d99f-409b-915b-f4c5d0241b02`,
415 );
416 writeLn(
417 ` bw delete ${useSharedFoldersTerm ? "org-shared-folder" : "org-collection"} ` +
418 "5cdfbd80-d99f-409b-915b-f4c5d0241b02 " +
419 "--organizationid 60556c31-e649-4b5d-8daf-fc1c391a1bf2",
420 );
421 writeLn(
422 " bw delete attachment b857igwl1dzrs2 --itemid 310d5ffd-e9a2-4451-af87-ea054dce0f78",
423 );
424 writeLn("", true);
425 })
426 .action(async (object, id, cmd) => {
427 if (!this.validateObject(object, deleteObjects, shownObjects)) {
428 return;
429 }
430
431 await this.exitIfLocked();
432 const command = new DeleteCommand(
433 this.serviceContainer.cipherService,
434 this.serviceContainer.folderService,
435 this.serviceContainer.apiService,
436 this.serviceContainer.folderApiService,
437 this.serviceContainer.billingAccountProfileStateService,
438 this.serviceContainer.cipherAuthorizationService,
439 this.serviceContainer.accountService,
440 this.serviceContainer.cliRestrictedItemTypesService,
441 );
442 const response = await command.run(object, id, cmd);
443 this.processResponse(response);
444 });
445 }

Callers 1

registerMethod · 0.95

Calls 6

visibleObjectsMethod · 0.95
validateObjectMethod · 0.95
runMethod · 0.95
actionMethod · 0.80
descriptionMethod · 0.45
processResponseMethod · 0.45

Tested by

no test coverage detected