Get the UUID in the --fields options

avoiney
avoiney
Community Member

Hi,

Would it be possible to add the UUID in the --fields option when use op get item.
This would make it simpler to then get topt when, for example, do a search on items. Here is my workflow (if you know a better way to do, tell me !):

op list items | jq ".[] | select(.overview.title | test(\"$1\"; \"i\"))" | op get item - --fields uuid,username,password,website,title | jq

And then I would like to get totp, but, as some objects have the same title, I need to use the UUID there. I know I could use jq to get all the fields, but the --fields is much simpler to use that jq to extract values.

Is there any reason to not provide the "uuid" option?

Thanks in advance,
Regards


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Sync Type: Not Provided

Comments

  • ag_yaron
    ag_yaron
    1Password Alumni

    Hey @avoiney ,

    I'm not entirely sure I fully comprehend what you are trying to do here (or how you're trying to do it), but in order to get the TOTP field of an item you can use:
    op get totp <item> [flags]

    As mentioned in our CLI reference guide: https://support.1password.com/command-line-reference/#get-totp

    You can add UUIDs instead of item's name/title, which will solve any duplicate items names issues, so it would look like so:
    op get totp <uuid> [flags]

    Does that answer your question or at least point you in the right direction?

  • avoiney
    avoiney
    Community Member

    Hi,

    Thanks for answering me!

    Actually, I am aware that I can get the totp from the title or the name of the item, but, when you have two items with the same title, the op get totp <title> output do not let you discrimintate which one you should use. So, by doing a first query with op get item <title> --fields username,title,website should give you some element to choose the one. But the UUID cannot be retrieve this way. And you will end by using jq.

    I managed to do it with jq, but it is a litlle bit unreadable:

    op list items | jq '.[] | select(.overview.title | test("<title>"; "i"))' | jq '{uuid}' | op get item - | jq '{title: .overview.title, uuid: .uuid, username: .overview.ainfo, url: .overview.url, password: .details.fields[] | select(.designation=="password").value}'

    Having the UUID in the --fields may allow to shorten command:

    op list items | jq '.[] | select(.overview.title | test("<title>"; "i"))' | jq '{uuid}' | op get item - --fields username,uuid,password,title,website

    The first part with the jq regexp test on op list items is here to get all possible results, as the op get item ask for an uuid in case of similar title.

    Regards,

  • ag_yaron
    ag_yaron
    1Password Alumni

    Thanks for clarifying @avoiney .

    We definitely have a long way to go with the output of the CLI and its readability, as well with the possible flexibility of the commands and APIs we have.
    I appreciate the feature request here, hopefully this is something that will be possible in the future! :+1:

  • avoiney
    avoiney
    Community Member

    You're welcome.
    The CLI is already awesome and very usefull on headless machines. I am a linux user and it allows me to use 1password without an openned browser so a big thanks to 1password developers!

    Have a nice day!

  • ag_yaron
    ag_yaron
    1Password Alumni

    Thank you for the kind words!

    We're glad to hear you find it so useful. Keep it up to date and stay tuned for more awesome features :)

This discussion has been closed.