aboutsummaryrefslogtreecommitdiffstats
path: root/executables/bin/get-password
blob: ca13d937be636d192ae631ab7f8638b70c29e757 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
set -e

VAULT="Private"
CREDENTIAL=""

main() {
	parse_args "$@"
	op read "op://$VAULT/$CREDENTIAL/password"
}

parse_args() {
	while [ $# -gt 0 ]; do
		case "$1" in
		--vault)
			VAULT="$2"
			shift 2
			;;
		--credential)
			CREDENTIAL="$2"
			shift 2
			;;
		*)
			echo "Usage: $0 [--vault <name>] --credential <name>"
			exit 1
			;;
		esac
	done

	if [ -z "$CREDENTIAL" ]; then
		echo "Invalid or empty CREDENTIAL" >&2
		exit 1
	fi
}

main "$@"