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