From a504c212ef307af55e9abbf0090e889f959a39af Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 30 Dec 2020 17:42:22 +0000 Subject: [PATCH] Adds perge-tags option --- inc/tag-management | 7 +++++++ kb | 2 ++ 2 files changed, 9 insertions(+) diff --git a/inc/tag-management b/inc/tag-management index 0e2c006..28d9202 100644 --- a/inc/tag-management +++ b/inc/tag-management @@ -75,3 +75,10 @@ listTags(){ GROUP BY tags.id" | sqlite3 --column $header "${sqliteFile}" } + +purgeTags(){ + vecho "purgeTags $*" + echo "DELETE FROM tags WHERE id IN ( + SELECT id FROM tags WHERE id NOT IN (SELECT tagID FROM links) + )"| sqlite3 --column --header "${sqliteFile}" +} diff --git a/kb b/kb index 91dc500..d005303 100755 --- a/kb +++ b/kb @@ -314,6 +314,7 @@ mainScript() { list-tags) listTags "${args[@]:1}"; safeExit ;; makedb) makedb; safeExit ;; new) newFile "${args[@]:1}"; safeExit ;; + purge-tags) purgeTags "${args[@]:1}"; safeExit ;; update) updateFileChange "${args[@]:1}"; safeExit ;; view) viewFile "${args[@]:1}"; safeExit ;; @@ -358,6 +359,7 @@ usage() { --normal List items of type \"normal\" list-tags Lists tags with the number of times its used --noheader Don't include the header + purge-tags Deletes any unused tags update [] Updates the database and git repo of a changed file If 2 files are given, it assumes a move view View a file