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

add getpwd parameter to have stout output. #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions keepassx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def create_db(args):
password = sys.stdin.read()
else:
password = getpass.getpass('Password: ')

password = password.strip(' \t\n\r')
password = encode_password(password)
db_file = open_db_file(args)
key_file = open_key_file(args)
Expand Down Expand Up @@ -96,6 +98,15 @@ def do_get(args):
clipboard.copy(entry.password)
sys.stderr.write("\nPassword has been copied to clipboard.\n")

def do_getpwd(args):
db = create_db(args)
try:
entry = _search_for_entry(db, args.entry_id)[0]
except EntryNotFoundError as e:
sys.stderr.write(str(e))
sys.stderr.write("\n")
return
print("%s" % (getattr(entry, 'password')))

def _search_for_entry(db, term):
entries = None
Expand Down Expand Up @@ -161,6 +172,11 @@ def create_parser():
dest="clipboard_copy", default=True,
help="Don't copy the password to the clipboard")
get_parser.set_defaults(run=do_get)

getpwd_parser = subparsers.add_parser('getpwd', help='Get password for entry')
getpwd_parser.add_argument('entry_id', help='Entry name or uuid.')
getpwd_parser.set_defaults(run=do_getpwd)

return parser


Expand Down
8 changes: 8 additions & 0 deletions python-keepassx.sublime-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"folders":
[
{
"path": "."
}
]
}