1
0
mirror of https://github.com/bitwarden/cli synced 2025-12-16 00:03:23 +00:00

Add bw get notes <id> command (#255)

Rationale: the notes object is a freeform plain-text field that's
prominently displayed in Web Vault. It is also useful for the CLI users
as discussed before in issues #81 and #196. I have some use cases
planned myself.

I was rather surprised this wasn't supported already, but the
implementation is simple and cannot really break any existing
functionality so here it is.
This commit is contained in:
Hannu Hartikainen
2021-05-12 05:19:47 +03:00
committed by GitHub
parent b4fc4ca3a5
commit 80f34d5de5
2 changed files with 20 additions and 0 deletions

View File

@@ -82,6 +82,8 @@ export class GetCommand extends DownloadCommand {
return await this.getUri(id);
case 'totp':
return await this.getTotp(id);
case 'notes':
return await this.getNotes(id);
case 'exposed':
return await this.getExposed(id);
case 'attachment':
@@ -239,6 +241,22 @@ export class GetCommand extends DownloadCommand {
return Response.success(res);
}
private async getNotes(id: string) {
const cipherResponse = await this.getCipher(id,
c => !Utils.isNullOrWhitespace(c.notes));
if (!cipherResponse.success) {
return cipherResponse;
}
const cipher = cipherResponse.data as CipherResponse;
if (Utils.isNullOrWhitespace(cipher.notes)) {
return Response.error('No notes available for this item.');
}
const res = new StringResponse(cipher.notes);
return Response.success(res);
}
private async getExposed(id: string) {
const passwordResponse = await this.getPassword(id);
if (!passwordResponse.success) {