1
0
Fork 0
mirror of https://codeberg.org/Reuh/feather.git synced 2025-10-27 10:09:32 +00:00

feat: add clear-data command

This commit is contained in:
Étienne Fildadut 2025-10-09 19:04:58 +02:00
parent ccf5b34b0d
commit 0d0cd491ec

15
main.py Normal file → Executable file
View file

@ -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()