Skip to content

Add --raw option to search command#232

Closed
sweharris wants to merge 1 commit intodoy:mainfrom
sweharris:search-raw
Closed

Add --raw option to search command#232
sweharris wants to merge 1 commit intodoy:mainfrom
sweharris:search-raw

Conversation

@sweharris
Copy link

As referenced in issue #230 this adds a --raw to search to dump the raw JSON results of a search.

eg

% rbw search --raw nosuchentry
[]

% rbw search --raw test | jq .
[
  {
    "id": "0315e272-b3d8-4dfa-a418-2b88a8599a96",
    "folder": null,
    "name": "Test",
    "data": {
      "username": "test1",
      "password": "test",
      "totp": null,
      "uris": []
    },
    "fields": [],
    "notes": null,
    "history": []
  },
  {
    "id": "44ef6aae-b088-4fef-a0fa-0ef9586a21f3",
    "folder": null,
    "name": "Test",
    "data": {
      "cardholder_name": "test",
      "number": "12345",
      "brand": null,
      "exp_month": null,
      "exp_year": null,
      "code": null
    },
    "fields": [],
    "notes": null,
    "history": []
  }
]

@doy
Copy link
Owner

doy commented Jul 21, 2025

implemented this separately in da48064

@doy doy closed this Jul 21, 2025
@sweharris
Copy link
Author

Hmm, your version doesn't seem to display all the fields, just a subset; (id, name, user, folder). The goal behind my --raw option was to dump the whole record so a user could then format it in shell to display whatever they wanted.

% rbw search --raw discord
[
  {
    "id": "2e62d994-4fe7-467a-85a9-7992945f486f",
    "name": "discord - user1",
    "user": "user1@login",
    "folder": "Chat"
  },
  {
    "id": "3d821c06-6f5c-4cfe-a63d-0d7f644c3f23",
    "name": "discord - user2",
    "user": "user2@login",
    "folder": null
  }
]

With this version the user would need to collect all the UUIDs and then do a get --raw on each to get similar data (so a total of 3 calls to rbw in my example, rather than 1).

I'm guessing this is because of ListField::all()

impl ListField {
    fn all() -> Vec<Self> {
        vec![Self::Id, Self::Name, Self::User, Self::Folder]
    }
}

Was this a deliberate choice?

@doy
Copy link
Owner

doy commented Jul 21, 2025

which fields are you interested in specifically?

@sweharris
Copy link
Author

My current script uses id, name, data.username, data.password, data.uris[].uri, data.totp, notes.

But it just seems to me that search --raw returning an array of the same elements get --raw does is more consistent and "least surprise"

@pschmitt
Copy link

My 2cts: I'd like to see all fields in the JSON. The more the better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants