def show(ctx, pass_name, clip, passthrough=False):
"""Decrypt and print a password named `pass-name`. If `--clip` or
`-c` is specified, do not print the password but instead copy the
first line to the clipboard using pyperclip. On Linux you will
need to have xclip/xsel and on OSX pbcopy/pbpaste installed.
"""
try:
data = ctx.obj.get_key(pass_name)
# If pass_name is actually a folder in the password store pass
# lists the folder instead.
except FileNotFoundError:
if not passthrough:
return ctx.invoke(ls, subfolder=pass_name, passthrough=True)
else:
click.echo(MSG_FILE_NOT_FOUND.format(pass_name))
return 1
except StoreNotInitialisedError:
click.echo(MSG_STORE_NOT_INITIALISED_ERROR)
return 1
except PermissionError:
click.echo(MSG_PERMISSION_ERROR)
return 1
if clip:
pyperclip.copy(data.split('\n')[0])
click.echo('Copied {0} to the clipboard.'.format(pass_name))
else:
# The key data always ends with a newline. So no need to add
# another one.
click.echo(data, nl=False)
评论列表
文章目录