()
| 526 | } |
| 527 | |
| 528 | private exportCommand(): Command { |
| 529 | return new Command("export") |
| 530 | .description("Export vault data to a CSV, JSON or ZIP file.") |
| 531 | .option("--output <output>", "Output directory or filename.") |
| 532 | .option("--format <format>", "Export file format.") |
| 533 | .option( |
| 534 | "--password [password]", |
| 535 | "Use password to encrypt instead of your Bitwarden account encryption key. Only applies to the encrypted_json format.", |
| 536 | ) |
| 537 | .option("--organizationid <organizationid>", "Organization id for an organization.") |
| 538 | .on("--help", () => { |
| 539 | writeLn("\n Notes:"); |
| 540 | writeLn(""); |
| 541 | writeLn( |
| 542 | " Valid formats are `csv`, `json`, `encrypted_json` and zip. Default format is `csv`.", |
| 543 | ); |
| 544 | writeLn(""); |
| 545 | writeLn( |
| 546 | " If --raw option is specified and no output filename or directory is given, the", |
| 547 | ); |
| 548 | writeLn(" result is written to stdout."); |
| 549 | writeLn(""); |
| 550 | writeLn(" Examples:"); |
| 551 | writeLn(""); |
| 552 | writeLn(" bw export"); |
| 553 | writeLn(" bw --raw export"); |
| 554 | writeLn(" bw export myPassword321"); |
| 555 | writeLn(" bw export myPassword321 --format json"); |
| 556 | writeLn(" bw export --output ./exp/bw.csv"); |
| 557 | writeLn(" bw export myPassword321 --output bw.json --format json"); |
| 558 | writeLn( |
| 559 | " bw export myPassword321 --organizationid 7063feab-4b10-472e-b64c-785e2b870b92", |
| 560 | ); |
| 561 | writeLn("", true); |
| 562 | }) |
| 563 | .action(async (options) => { |
| 564 | await this.exitIfLocked(); |
| 565 | const command = new ExportCommand( |
| 566 | this.serviceContainer.exportService, |
| 567 | this.serviceContainer.policyService, |
| 568 | this.serviceContainer.eventCollectionService, |
| 569 | this.serviceContainer.accountService, |
| 570 | ); |
| 571 | const response = await command.run(options); |
| 572 | this.processResponse(response); |
| 573 | }); |
| 574 | } |
| 575 | } |
no test coverage detected