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

Method createCommand

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

Source from the content-addressed store, hash-verified

207 }
208
209 private createCommand() {
210 const createObjects = ["item", "attachment", "folder", "org-collection"];
211 return new Command("create")
212 .argument("<object>", "Valid objects are: " + createObjects.join(", "))
213 .argument(
214 "[encodedJson]",
215 "Encoded json of the object to create. Can also be piped into stdin.",
216 )
217 .description("Create an object in the vault.")
218 .option("--file <file>", "Path to file for attachment.")
219 .option("--itemid <itemid>", "Attachment's item id.")
220 .option("--organizationid <organizationid>", "Organization id for an organization object.")
221 .on("--help", () => {
222 writeLn("\n Examples:");
223 writeLn("");
224 writeLn(" bw create folder eyJuYW1lIjoiTXkgRm9sZGVyIn0K");
225 writeLn(" echo 'eyJuYW1lIjoiTXkgRm9sZGVyIn0K' | bw create folder");
226 writeLn(
227 " bw create attachment --file ./myfile.csv " +
228 "--itemid 16b15b89-65b3-4639-ad2a-95052a6d8f66",
229 );
230 writeLn("", true);
231 })
232 .action(async (object, encodedJson, cmd) => {
233 if (!this.validateObject(object, createObjects)) {
234 return;
235 }
236
237 await this.exitIfLocked();
238 const command = new CreateCommand(
239 this.serviceContainer.cipherService,
240 this.serviceContainer.folderService,
241 this.serviceContainer.keyService,
242 this.serviceContainer.encryptService,
243 this.serviceContainer.apiService,
244 this.serviceContainer.folderApiService,
245 this.serviceContainer.billingAccountProfileStateService,
246 this.serviceContainer.organizationService,
247 this.serviceContainer.accountService,
248 this.serviceContainer.cliRestrictedItemTypesService,
249 this.serviceContainer.configService,
250 );
251 const response = await command.run(object, encodedJson, cmd);
252 this.processResponse(response);
253 });
254 }
255
256 private editCommand(): Command {
257 const editObjects = ["item", "item-collections", "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