mirror of
https://codeberg.org/Reuh/feather.git
synced 2025-10-27 18:19:32 +00:00
feat: add clear-data command
This commit is contained in:
parent
ccf5b34b0d
commit
0d0cd491ec
1 changed files with 13 additions and 2 deletions
15
main.py
Normal file → Executable file
15
main.py
Normal file → Executable file
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
|
@ -288,6 +290,13 @@ def regenerate_files(config):
|
||||||
# rewrite HTML
|
# rewrite HTML
|
||||||
generate_html_for_item(config, item_json, regenerate=True)
|
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
|
#%% Run feather
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
@ -296,8 +305,8 @@ def main():
|
||||||
description="file-based RSS reader"
|
description="file-based RSS reader"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"action", choices=("sync", "sync-up", "sync-down", "daemon", "regenerate"),
|
"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"
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
@ -319,6 +328,8 @@ def main():
|
||||||
pass
|
pass
|
||||||
elif args.action == "regenerate":
|
elif args.action == "regenerate":
|
||||||
regenerate_files(config)
|
regenerate_files(config)
|
||||||
|
elif args.action == "clear-data":
|
||||||
|
clear_data(config)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue