Skip to content

Get resource by search term #65

@aminnairi

Description

@aminnairi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions