Implement "rm" subcommand

This commit is contained in:
The Magician 2023-12-19 12:12:20 +00:00
parent adea4b4c97
commit 9c7492bed5
2 changed files with 16 additions and 0 deletions

View File

@ -1,5 +1,7 @@
test:
bash_unit ./tests/test_*.sh
runtests:
ls -1 zk tests/* | entr -c bash_unit ./tests/test_*.sh
install:
test -d ~/.local/bin/ || mkdir -p ~/.local/bin/
cp zk ~/.local/bin/zk

14
zk
View File

@ -63,6 +63,20 @@ _zk_edit() {
fi
}
_zk_rm() {
if test -z "$1"; then
echo "zk rm: no zettel id given" 1>&2
exit 1
fi
if ! find "$ZKDIR" -name "$1" | grep .; then
echo "zk rm: zettel "$1" not found" 1>&2
exit 2
fi
rm "$ZKDIR/$1"
}
main() {
check_zkdir