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: test:
bash_unit ./tests/test_*.sh bash_unit ./tests/test_*.sh
runtests:
ls -1 zk tests/* | entr -c bash_unit ./tests/test_*.sh
install: install:
test -d ~/.local/bin/ || mkdir -p ~/.local/bin/ test -d ~/.local/bin/ || mkdir -p ~/.local/bin/
cp zk ~/.local/bin/zk cp zk ~/.local/bin/zk

14
zk
View File

@ -63,6 +63,20 @@ _zk_edit() {
fi 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() { main() {
check_zkdir check_zkdir