feat: way better argument parsing, cleaner structure and future-proof routing

This commit is contained in:
2025-12-14 11:21:38 +01:00
parent cf83b18b43
commit 429f1b4881

62
main.py
View File

@@ -3,24 +3,64 @@
import sys import sys
import argparse import argparse
from skywipe.commands import * from skywipe.commands import run_configure
from skywipe.configuration import Configuration
COMMANDS = {
"all": "target everything",
"configure": "create configuration",
"posts": "only posts",
"medias": "only posts with medias",
"likes": "only likes",
"reposts": "only reposts",
"follows": "only follows",
}
def _create_parser():
parser = argparse.ArgumentParser(
description="Clean your bluesky account with style.",
epilog="WARNING: This tool performs destructive operations. Only use it if you intend to erase data from your Bluesky account."
)
subparsers = parser.add_subparsers(
dest="command",
help="Command to execute",
metavar="COMMAND",
required=True
)
for cmd, help_text in COMMANDS.items():
subparsers.add_parser(cmd, help=help_text)
return parser
def _check_config_required(command: str) -> bool:
return command != "configure"
def _require_config():
config = Configuration()
if not config.exists():
print("Error: Configuration file not found.")
print("You must run 'skywipe configure' first.")
sys.exit(1)
def main(): def main():
parser = argparse.ArgumentParser( parser = _create_parser()
description="Clean your bluesky account with style")
parser.add_argument(
"command",
choices=["all", "configure", "posts",
"medias", "likes", "reposts", "follows"],
help="Command to execute"
)
args = parser.parse_args() args = parser.parse_args()
if _check_config_required(args.command):
_require_config()
if args.command == "configure": if args.command == "configure":
run_configure() run_configure()
else:
print(f"Command '{args.command}' is not yet implemented.")
if __name__ == '__main__': if __name__ == '__main__':
main() main()