lastpass / lastpass-cli

LastPass command line interface tool
GNU General Public License v2.0
2.85k stars 292 forks source link

JSON output for lpass ls #560

Open googol opened 4 years ago

googol commented 4 years ago

Hi,

it would be great to have json output for the account list, to be able to more easily parse it in scripts. The current textual format is a bit painful

Example format that would be good for my needs:

[
  {
    "id": 123123123123,
    "name": "the name of the account",
    "type": "password",
    "path": ["Shared folder", "subfolder", "subsubfolder"],
    "pathString": "Shared folder/subfolder/subsubfolder"
  }
]
ilya-bc commented 4 years ago

@googol Looks like this is available but not really documented.

$ lpass show "SSH Keys" --json

Although there are some issues with that:

googol commented 4 years ago

As far as I understand lpass show only shows details of a single account, unlike lpass ls, which lists all the accounts, which is what I'm after. Does lpass show actually do an account list as well?

knksmith57 commented 3 years ago

For posterity, until proper --json support is added to ls, it is possible to coerce show to behave like ls with a clever combination of --expand-multi and --basic-regexp:

❯ lpass show --expand-multi --basic-regexp '.*' --json

Or, shortened for brevity:

❯ lpass show -xjG '.*'

see https://github.com/lastpass/lastpass-cli/issues/581#issue-739346990 for more color / examples