implement '--clear-cache'

Effectively clears all cached values from the cache database by
executing "DELETE FROM data" without any further user input.
This commit is contained in:
Mike Fährmann
2019-04-25 21:30:16 +02:00
parent 0318c610dc
commit bc26fc2439
3 changed files with 48 additions and 11 deletions

View File

@@ -181,6 +181,18 @@ def main():
if test:
print("Example :", test[0])
print()
elif args.clear_cache:
from . import cache
log = logging.getLogger("cache")
cnt = cache.clear()
if cnt is None:
log.error("Database file not available")
else:
log.info(
"Deleted %d %s from '%s'",
cnt, "entry" if cnt == 1 else "entries", cache._path(),
)
else:
if not args.urls and not args.inputfile:
parser.error(