(useSharedFoldersTerm: boolean)
| 263 | } |
| 264 | |
| 265 | private createCommand(useSharedFoldersTerm: boolean): Command { |
| 266 | const createObjects = [ |
| 267 | "item", |
| 268 | "attachment", |
| 269 | "folder", |
| 270 | "my-folder", |
| 271 | "org-collection", |
| 272 | "org-shared-folder", |
| 273 | ]; |
| 274 | const shownObjects = this.visibleObjects(createObjects, useSharedFoldersTerm); |
| 275 | return new Command("create") |
| 276 | .argument("<object>", "Valid objects are: " + shownObjects.join(", ")) |
| 277 | .argument( |
| 278 | "[encodedJson]", |
| 279 | "Encoded json of the object to create. Can also be piped into stdin.", |
| 280 | ) |
| 281 | .description("Create an object in the vault.") |
| 282 | .option("--file <file>", "Path to file for attachment.") |
| 283 | .option("--itemid <itemid>", "Attachment's item id.") |
| 284 | .option("--organizationid <organizationid>", "Organization id for an organization object.") |
| 285 | .on("--help", () => { |
| 286 | writeLn("\n Examples:"); |
| 287 | writeLn(""); |
| 288 | const folderObject = useSharedFoldersTerm ? "my-folder" : "folder"; |
| 289 | writeLn(` bw create ${folderObject} eyJuYW1lIjoiTXkgRm9sZGVyIn0K`); |
| 290 | writeLn(` echo 'eyJuYW1lIjoiTXkgRm9sZGVyIn0K' | bw create ${folderObject}`); |
| 291 | writeLn( |
| 292 | ` bw create ${useSharedFoldersTerm ? "org-shared-folder" : "org-collection"} eyJuYW1lIjoiTXkgRm9sZGVyIn0K ` + |
| 293 | "--organizationid 60556c31-e649-4b5d-8daf-fc1c391a1bf2", |
| 294 | ); |
| 295 | writeLn( |
| 296 | " bw create attachment --file ./myfile.csv " + |
| 297 | "--itemid 16b15b89-65b3-4639-ad2a-95052a6d8f66", |
| 298 | ); |
| 299 | writeLn("", true); |
| 300 | }) |
| 301 | .action(async (object, encodedJson, cmd) => { |
| 302 | if (!this.validateObject(object, createObjects, shownObjects)) { |
| 303 | return; |
| 304 | } |
| 305 | |
| 306 | await this.exitIfLocked(); |
| 307 | const command = new CreateCommand( |
| 308 | this.serviceContainer.cipherService, |
| 309 | this.serviceContainer.folderService, |
| 310 | this.serviceContainer.keyService, |
| 311 | this.serviceContainer.encryptService, |
| 312 | this.serviceContainer.apiService, |
| 313 | this.serviceContainer.folderApiService, |
| 314 | this.serviceContainer.billingAccountProfileStateService, |
| 315 | this.serviceContainer.organizationService, |
| 316 | this.serviceContainer.accountService, |
| 317 | this.serviceContainer.cliRestrictedItemTypesService, |
| 318 | this.serviceContainer.configService, |
| 319 | ); |
| 320 | const response = await command.run(object, encodedJson, cmd); |
| 321 | this.processResponse(response); |
| 322 | }); |
no test coverage detected