diff --git a/main.py b/main.py old mode 100644 new mode 100755 index 1a2805c..21012ec --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +#!/usr/bin/python3 + import os import re import json @@ -288,6 +290,13 @@ def regenerate_files(config): # rewrite HTML generate_html_for_item(config, item_json, regenerate=True) +def clear_data(config): + for json_path in config.json_root.glob("*.json"): + item_json = json.load(json_path.open("r")) + remove_html_for_item(config, item_json, ignore_deleted=True) + json_path.unlink() + remove_empty_html_directories(config) + #%% Run feather def main(): @@ -296,8 +305,8 @@ def main(): description="file-based RSS reader" ) parser.add_argument( - "action", choices=("sync", "sync-up", "sync-down", "daemon", "regenerate"), - help="sync: perform a full synchronization with the server; sync-up: only synchronize local changes to the server (e.g. items read locally); sync-down: only synchronize remote change from the server (e.g. new items or items read from another device); daemon: start in daemon mode (will keep performing synchronizations periodically until process is stopped); regenerate: regenerate all HTML files from the local data" + "action", choices=("sync", "sync-up", "sync-down", "daemon", "regenerate", "clear-data"), + help="sync: perform a full synchronization with the server; sync-up: only synchronize local changes to the server (e.g. items read locally); sync-down: only synchronize remote change from the server (e.g. new items or items read from another device); daemon: start in daemon mode (will keep performing synchronizations periodically until process is stopped); regenerate: regenerate all HTML files from the local data; clear-data: remove all local data" ) args = parser.parse_args() @@ -319,6 +328,8 @@ def main(): pass elif args.action == "regenerate": regenerate_files(config) + elif args.action == "clear-data": + clear_data(config) if __name__ == "__main__": main()