Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get resource by search term #65

Open
aminnairi opened this issue Jan 4, 2025 · 0 comments
Open

Get resource by search term #65

aminnairi opened this issue Jan 4, 2025 · 0 comments

Comments

@aminnairi
Copy link

aminnairi commented Jan 4, 2025

Description

As a user, it would be great to be able to get a resource by a search term rather than its ID which is not user-friendly.

It would be even better to allow picking the item from a list if there are many matches. This is something that may be implemented in Node.js using @inquirer/prompts, but I'm not familiar enough with the Go environment to find any alternatives.

passbolt get resource --search slash
# Display the result if one entry matches, or allow to pick if many entries matches

Or even better in the point of view of a user, without any parameters

passbolt get resource slash
# Where "slash" is the search term

Additional information

If using a Fish shell, it is possible to create a Fish function to copy to the clipboard the result of a search by using the following code

function pass -a search
  passbolt get resource --id (passbolt list resource | grep $search | cut -d " " -f 1) | grep Password | cut -d " " -f 2 | xclip -selection clipboard
end

This function:

  • First list resource
  • Then filters out anything that does not match the search
  • Get the first column (containing the id)
  • Then feed this to the passbolt cli to get the resource by its id
  • Filter out the lines to only retain the password line
  • Get the second column (containing the password)
  • Copy it to the clipboard

This could go even further if using a fuzzy matcher like fzf by simply replacing for grep

function pass
  passbolt get resource --id (passbolt list resource | fzf | cut -d " " -f 1) | grep Password | cut -d " " -f 2 | xclip -selection clipboard
end
@aminnairi aminnairi changed the title Get resource by host Get resource by search term Jan 4, 2025
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

No branches or pull requests

1 participant