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

Method editCommand

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

Source from the content-addressed store, hash-verified

254 }
255
256 private editCommand(): Command {
257 const editObjects = ["item", "item-collections", "folder", "org-collection"];
258 return new Command("edit")
259 .argument("<object>", "Valid objects are: " + editObjects.join(", "))
260 .argument("<id>", "Object's globally unique `id`.")
261 .argument(
262 "[encodedJson]",
263 "Encoded json of the object to create. Can also be piped into stdin.",
264 )
265 .description("Edit an object from the vault.")
266 .option("--organizationid <organizationid>", "Organization id for an organization object.")
267 .on("--help", () => {
268 writeLn("\n Examples:");
269 writeLn("");
270 writeLn(
271 " bw edit folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02 eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==",
272 );
273 writeLn(
274 " echo 'eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==' | " +
275 "bw edit folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02",
276 );
277 writeLn(
278 " bw edit item-collections 78307355-fd25-416b-88b8-b33fd0e88c82 " +
279 "WyI5NzQwNTNkMC0zYjMzLTRiOTgtODg2ZS1mZWNmNWM4ZGJhOTYiXQ==",
280 );
281 writeLn("", true);
282 })
283 .action(async (object, id, encodedJson, cmd) => {
284 if (!this.validateObject(object, editObjects)) {
285 return;
286 }
287
288 await this.exitIfLocked();
289 const command = new EditCommand(
290 this.serviceContainer.cipherService,
291 this.serviceContainer.folderService,
292 this.serviceContainer.keyService,
293 this.serviceContainer.encryptService,
294 this.serviceContainer.apiService,
295 this.serviceContainer.folderApiService,
296 this.serviceContainer.accountService,
297 this.serviceContainer.cliRestrictedItemTypesService,
298 this.serviceContainer.policyService,
299 this.serviceContainer.billingAccountProfileStateService,
300 this.serviceContainer.cipherAuthorizationService,
301 );
302 const response = await command.run(object, id, encodedJson, cmd);
303 this.processResponse(response);
304 });
305 }
306
307 private deleteCommand(): Command {
308 const deleteObjects = ["item", "attachment", "folder", "org-collection"];

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