()
| 95 | } |
| 96 | |
| 97 | private receiveCommand(): Command { |
| 98 | return new Command("receive") |
| 99 | .arguments("<url>") |
| 100 | .description("Access a Bitwarden Send from a url") |
| 101 | .option("--password <password>", "Password needed to access the Send.") |
| 102 | .option("--passwordenv <passwordenv>", "Environment variable storing the Send's password") |
| 103 | .option( |
| 104 | "--passwordfile <passwordfile>", |
| 105 | "Path to a file containing the Sends password as its first line", |
| 106 | ) |
| 107 | .option("--obj", "Return the Send's json object rather than the Send's content") |
| 108 | .option("--output <location>", "Specify a file path to save a File-type Send to") |
| 109 | .on("--help", () => { |
| 110 | writeLn(""); |
| 111 | writeLn( |
| 112 | "If a password is required, the provided password is used or the user is prompted.", |
| 113 | ); |
| 114 | writeLn("", true); |
| 115 | }) |
| 116 | .action(async (url: string, options: OptionValues, command: Command) => { |
| 117 | const cmd = new SendReceiveCommand( |
| 118 | this.serviceContainer.encryptService, |
| 119 | this.serviceContainer.cryptoFunctionService, |
| 120 | this.serviceContainer.platformUtilsService, |
| 121 | this.serviceContainer.environmentService, |
| 122 | this.serviceContainer.sendApiService, |
| 123 | this.serviceContainer.apiService, |
| 124 | this.serviceContainer.sendTokenService, |
| 125 | this.serviceContainer.sendDecryptionService, |
| 126 | this.serviceContainer.appIdService, |
| 127 | this.serviceContainer.configService, |
| 128 | this.serviceContainer.customUserAgent, |
| 129 | ); |
| 130 | // When invoked as `bw send receive`, the parent `send` command also declares |
| 131 | // `--password`, so commander binds the flag to the parent and this subcommand's |
| 132 | // `options.password` is undefined. `optsWithGlobals()` merges ancestor options so the |
| 133 | // password is resolved for both `bw send receive` and top-level `bw receive`. (PM-24945) |
| 134 | const response = await cmd.run(url, command.optsWithGlobals()); |
| 135 | this.processResponse(response); |
| 136 | }); |
| 137 | } |
| 138 | |
| 139 | private listCommand(): Command { |
| 140 | return new Command("list") |
no test coverage detected