Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Commit

Permalink
Better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dmotte committed Jun 30, 2022
1 parent 435525b commit 54a21f8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sshkp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ def main(argv=None):

args = vars(parser.parse_args(argv[1:]))

############################################################################

entryname = args['entryname']
command = args['command']

############################################################################

kp_filename = os.getenv('KP_FILENAME')
kp_password = os.getenv('KP_PASSWORD')

if kp_filename is None:
raise Exception('KP_FILENAME environment variable not defined')
print('KP_FILENAME environment variable not defined', file=sys.stderr)
return 1
if kp_password is None:
kp_password = getpass.getpass('KeePass password: ')

Expand All @@ -47,7 +48,8 @@ def main(argv=None):
entry = kp.find_entries_by_title(entryname, first=True)

if entry is None:
raise Exception('KeePass entry not found')
print('KeePass entry not found', file=sys.stderr)
return 1

############################################################################

Expand Down

0 comments on commit 54a21f8

Please sign in to comment.