Merge xsekrit into credentials
This commit is contained in:
parent
83d15c417d
commit
01c6a6d22d
@ -16,7 +16,7 @@ PREFIX = $(HOME)
|
||||
MANPREFIX = $(PREFIX)/local
|
||||
BIN = ZZZ browser credentials fetch flac2ogg imgresize invidious \
|
||||
riot-web-ui rfcopen screenshot sekrit tor-browser \
|
||||
w3m-copy-link xsekrit
|
||||
w3m-copy-link
|
||||
MAN1 = sekrit.1
|
||||
|
||||
all: $(BIN)
|
||||
|
@ -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
|
||||
|
||||
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
|
||||
|
@ -1,27 +0,0 @@
|
||||
#!/bin/sh
|
||||
# xsekrit
|
||||
# Written in 2019 by Lucas
|
||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all
|
||||
# copyright and related and neighboring rights to this software to the
|
||||
# public domain worldwide. This software is distributed without any
|
||||
# warranty. You should have received a copy of the CC0 Public Domain
|
||||
# Dedication along with this software. If not, see
|
||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
printf "Usage: %s key\n" "${0##*/}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
err()
|
||||
{
|
||||
printf "%s: %s\n" "${0##*/}" "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ $# -eq 1 ] && [ -n "$1" ] || usage
|
||||
sekrit has "$1" || err "Unknown key \"$1\"."
|
||||
sekrit get "$1" | xclip -q -r -l 1 -sel clip 2>/dev/null
|
Loading…
Reference in New Issue
Block a user