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

Method deleteCommand

apps/cli/src/vault.program.ts:307–349  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

305 }
306
307 private deleteCommand(): Command {
308 const deleteObjects = ["item", "attachment", "folder", "org-collection"];
309 return new Command("delete")
310 .argument("<object>", "Valid objects are: " + deleteObjects.join(", "))
311 .argument("<id>", "Object's globally unique `id`.")
312 .description("Delete an object from the vault.")
313 .option("--itemid <itemid>", "Attachment's item id.")
314 .option("--organizationid <organizationid>", "Organization id for an organization object.")
315 .option(
316 "-p, --permanent",
317 "Permanently deletes the item instead of soft-deleting it (item only).",
318 )
319 .on("--help", () => {
320 writeLn("\n Examples:");
321 writeLn("");
322 writeLn(" bw delete item 7063feab-4b10-472e-b64c-785e2b870b92");
323 writeLn(" bw delete item 89c21cd2-fab0-4f69-8c6e-ab8a0168f69a --permanent");
324 writeLn(" bw delete folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02");
325 writeLn(
326 " bw delete attachment b857igwl1dzrs2 --itemid 310d5ffd-e9a2-4451-af87-ea054dce0f78",
327 );
328 writeLn("", true);
329 })
330 .action(async (object, id, cmd) => {
331 if (!this.validateObject(object, deleteObjects)) {
332 return;
333 }
334
335 await this.exitIfLocked();
336 const command = new DeleteCommand(
337 this.serviceContainer.cipherService,
338 this.serviceContainer.folderService,
339 this.serviceContainer.apiService,
340 this.serviceContainer.folderApiService,
341 this.serviceContainer.billingAccountProfileStateService,
342 this.serviceContainer.cipherAuthorizationService,
343 this.serviceContainer.accountService,
344 this.serviceContainer.cliRestrictedItemTypesService,
345 );
346 const response = await command.run(object, id, cmd);
347 this.processResponse(response);
348 });
349 }
350
351 private archiveCommand(): Command {
352 const archiveObjects = ["item"];

Callers 1

registerMethod · 0.95

Calls 5

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

Tested by

no test coverage detected