sekrit: add rm command
While at it, fix a typo.
This commit is contained in:
parent
19631627d6
commit
e71a6eb321
13
bin/sekrit.1
13
bin/sekrit.1
@ -38,6 +38,11 @@
|
|||||||
.Nm
|
.Nm
|
||||||
.Cm ls
|
.Cm ls
|
||||||
.Op Ar keys ...
|
.Op Ar keys ...
|
||||||
|
.Nm
|
||||||
|
.Cm rm
|
||||||
|
.Op Fl f
|
||||||
|
.Ar key
|
||||||
|
.Op Ar key ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
is a small shell script for managing encrypted files.
|
is a small shell script for managing encrypted files.
|
||||||
@ -104,7 +109,13 @@ given as argument,
|
|||||||
list all the registered keys under that hierarchy.
|
list all the registered keys under that hierarchy.
|
||||||
If no
|
If no
|
||||||
.Ar key
|
.Ar key
|
||||||
is given, list all the registeres keys.
|
is given, list all the registered keys.
|
||||||
|
.It Nm Cm rm Oo Fl f Oc Ar key Op Ar key ...
|
||||||
|
Removes the file associated with each
|
||||||
|
.Ar key .
|
||||||
|
Asks for confirmation before removing each file, unless
|
||||||
|
.Fl f
|
||||||
|
is given.
|
||||||
.El
|
.El
|
||||||
.Sh ENVIRONMENT
|
.Sh ENVIRONMENT
|
||||||
.Bl -tag -width SEKRIT_GPG_ID
|
.Bl -tag -width SEKRIT_GPG_ID
|
||||||
|
@ -35,6 +35,7 @@ Usage:
|
|||||||
${0##*/} get key
|
${0##*/} get key
|
||||||
${0##*/} has key
|
${0##*/} has key
|
||||||
${0##*/} ls [keys ...]
|
${0##*/} ls [keys ...]
|
||||||
|
${0##*/} rm [-f] key [key ...]
|
||||||
|
|
||||||
If no value was provided on command line, add reads from stdin.
|
If no value was provided on command line, add reads from stdin.
|
||||||
.
|
.
|
||||||
@ -116,8 +117,8 @@ sekrit_cp()
|
|||||||
|
|
||||||
sekrit_gen()
|
sekrit_gen()
|
||||||
{
|
{
|
||||||
len=43
|
|
||||||
OPTIND=1
|
OPTIND=1
|
||||||
|
len=43
|
||||||
while getopts l: flag; do
|
while getopts l: flag; do
|
||||||
case "$flag" in
|
case "$flag" in
|
||||||
l) len=$(to_number "$OPTARG") ||
|
l) len=$(to_number "$OPTARG") ||
|
||||||
@ -179,6 +180,30 @@ sekrit_ls()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sekrit_rm()
|
||||||
|
{
|
||||||
|
OPTIND=1
|
||||||
|
fflag=
|
||||||
|
while getopts f flag; do
|
||||||
|
case "$flag" in
|
||||||
|
f) fflag=-f ;;
|
||||||
|
*) usage ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
[ $# -ge 1 ] || usage
|
||||||
|
|
||||||
|
for key; do
|
||||||
|
path=$(make_key_path "$key")
|
||||||
|
if [ ! -f "$path" ]; then
|
||||||
|
printf "%s: no data for key %s\n" "${0##*/}" "$key" >&2
|
||||||
|
else
|
||||||
|
rm -i $fflag "$path"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
[ $# -ge 1 ] || usage
|
[ $# -ge 1 ] || usage
|
||||||
@ -198,5 +223,6 @@ gen) sekrit_gen "$@" ;;
|
|||||||
get) sekrit_get "$@" ;;
|
get) sekrit_get "$@" ;;
|
||||||
has) sekrit_has "$@" ;;
|
has) sekrit_has "$@" ;;
|
||||||
ls) sekrit_ls "$@" ;;
|
ls) sekrit_ls "$@" ;;
|
||||||
|
rm) sekrit_rm "$@" ;;
|
||||||
*) usage ;;
|
*) usage ;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user