Merge xsekrit into credentials
This commit is contained in:
parent
83d15c417d
commit
01c6a6d22d
3 changed files with 28 additions and 31 deletions
|
@ -12,7 +12,11 @@
|
|||
|
||||
usage()
|
||||
{
|
||||
printf "Usage: %s [-2pu] service\n" "${0##*/}" >&2
|
||||
cat - <<. >&2
|
||||
Usage:
|
||||
${0##*/} [-2pu] service
|
||||
${0##*/} -r key
|
||||
.
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -86,15 +90,28 @@ get_service()
|
|||
[ $sfa = yes ] && get_2fa "$service"
|
||||
}
|
||||
|
||||
get_raw()
|
||||
{
|
||||
key=$1
|
||||
|
||||
sekrit has "$key" || err "Unknown key \"$key\"."
|
||||
|
||||
printf "%s" "$key"
|
||||
sekrit get "$key" | clip && printf "\n"
|
||||
}
|
||||
|
||||
sfa=no
|
||||
pass=no
|
||||
raw=no
|
||||
user=no
|
||||
while getopts 2pu flag; do
|
||||
while getopts 2pru flag; do
|
||||
case $flag in
|
||||
2) sfa=check
|
||||
;;
|
||||
p) pass=check
|
||||
;;
|
||||
r) raw=yes
|
||||
;;
|
||||
u) user=check
|
||||
;;
|
||||
*) usage
|
||||
|
@ -106,4 +123,11 @@ shift $(($OPTIND - 1))
|
|||
[ $# -eq 1 ] && [ -n "$1" ] || usage
|
||||
key=$1
|
||||
|
||||
get_service "$key" $user $pass $sfa
|
||||
if [ $raw = yes ]; then
|
||||
if [ $sfa != no ] || [ $pass != no ] || [ $user != no ]; then
|
||||
err "-r is mutually exclusive with -2pu."
|
||||
fi
|
||||
get_raw "$key"
|
||||
else
|
||||
get_service "$key" $user $pass $sfa
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue