()
| 132 | } |
| 133 | |
| 134 | private getCommand(): Command { |
| 135 | const getObjects = [ |
| 136 | "item", |
| 137 | "username", |
| 138 | "password", |
| 139 | "uri", |
| 140 | "totp", |
| 141 | "notes", |
| 142 | "exposed", |
| 143 | "attachment", |
| 144 | "folder", |
| 145 | "collection", |
| 146 | "org-collection", |
| 147 | "organization", |
| 148 | "template", |
| 149 | "fingerprint", |
| 150 | "send", |
| 151 | ]; |
| 152 | return new Command("get") |
| 153 | .argument("<object>", "Valid objects are: " + getObjects.join(", ")) |
| 154 | .argument("<id>", "Search term or object's globally unique `id`.") |
| 155 | .description("Get an object from the vault.") |
| 156 | .option("--itemid <itemid>", "Attachment's item id.") |
| 157 | .option("--output <output>", "Output directory or filename for attachment.") |
| 158 | .option("--organizationid <organizationid>", "Organization id for an organization object.") |
| 159 | .on("--help", () => { |
| 160 | writeLn("\n If raw output is specified and no output filename or directory is given for"); |
| 161 | writeLn(" an attachment query, the attachment content is written to stdout."); |
| 162 | writeLn(""); |
| 163 | writeLn(" Examples:"); |
| 164 | writeLn(""); |
| 165 | writeLn(" bw get item 99ee88d2-6046-4ea7-92c2-acac464b1412"); |
| 166 | writeLn(" bw get password https://google.com"); |
| 167 | writeLn(" bw get totp google.com"); |
| 168 | writeLn(" bw get notes google.com"); |
| 169 | writeLn(" bw get exposed yahoo.com"); |
| 170 | writeLn( |
| 171 | " bw get attachment b857igwl1dzrs2 --itemid 99ee88d2-6046-4ea7-92c2-acac464b1412 " + |
| 172 | "--output ./photo.jpg", |
| 173 | ); |
| 174 | writeLn( |
| 175 | " bw get attachment photo.jpg --itemid 99ee88d2-6046-4ea7-92c2-acac464b1412 --raw", |
| 176 | ); |
| 177 | writeLn(" bw get folder email"); |
| 178 | writeLn(" bw get template folder"); |
| 179 | writeLn("", true); |
| 180 | }) |
| 181 | .action(async (object, id, cmd) => { |
| 182 | if (!this.validateObject(object, getObjects)) { |
| 183 | return; |
| 184 | } |
| 185 | |
| 186 | await this.exitIfLocked(); |
| 187 | const command = new GetCommand( |
| 188 | this.serviceContainer.cipherService, |
| 189 | this.serviceContainer.folderService, |
| 190 | this.serviceContainer.collectionService, |
| 191 | this.serviceContainer.totpService, |
no test coverage detected