go-passbolt-cli icon indicating copy to clipboard operation
go-passbolt-cli copied to clipboard

Get resource by search term

Open aminnairi opened this issue 11 months ago • 1 comments

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 avatar Jan 04 '25 17:01 aminnairi

Hi, you can already Filter using the CEL Syntax with the --filter flag in list commands https://github.com/passbolt/go-passbolt-cli/wiki/passbolt_list

An interactive mode is something i always planned to do but never found time to actually do.

speatzle avatar Jan 10 '25 13:01 speatzle