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

Commit

Permalink
Fix bug with --help flag
Browse files Browse the repository at this point in the history
When you started rofi-keepassxc with `--help` flag rofi-keepassxc has asked you for password.
  • Loading branch information
wzykubek committed Mar 29, 2020
1 parent d773f5e commit e1e403e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions rofi-keepassxc
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/usr/bin/env zsh

CACHE=$HOME/.cache/rofi-keepassxc/
mkdir -p $CACHE

DBPASS=$(rofi -dmenu -i -p "Enter your database password" -l 0 -password -width 500)
[ ! "$DBPASS" ] && exit

clip_username() {
echo $DBPASS | keepassxc-cli show $DB $ENTRY | grep 'UserName:' | cut -b 11- | xclip -selection clipboard
}
Expand Down Expand Up @@ -159,16 +153,23 @@ choose_action() {
case "$1" in
-h || --help)
echo "
usage: rofi-keepassxc [-h] [-d]
usage: rofi-keepassxc [-h] [-d]
arguments:
-h, --help show this help message and exit
-d, --database specify keepass database file path
arguments:
-h, --help show this help message and exit
-d, --database [file] specify keepass database file path
"
exit;;
-d || --database) DB="$2" ;;
*) echo "[E] Invalid argument."; exit ;;
esac

CACHE=$HOME/.cache/rofi-keepassxc/
mkdir -p $CACHE

DBPASS=$(rofi -dmenu -i -p "Enter your database password" -l 0 -password -width 500)
[ ! "$DBPASS" ] && exit

ERROR_PASS='Error while reading the database'
CHECK_PASS=$(echo $DBPASS | keepassxc-cli open $DB &> $CACHE/tmp && grep -oh $ERROR_PASS $CACHE/tmp)
ERROR_DB='Failed to open database file'
Expand Down

0 comments on commit e1e403e

Please sign in to comment.