diff --git a/fimfarchive/__main__.py b/fimfarchive/__main__.py index 8712502..75ddc88 100644 --- a/fimfarchive/__main__.py +++ b/fimfarchive/__main__.py @@ -5,7 +5,7 @@ # # Fimfarchive, preserves stories from Fimfiction. -# Copyright (C) 2019 Joakim Soderlund +# Copyright (C) 2024 Joakim Soderlund # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,12 +22,6 @@ # -import sys +from fimfarchive.commands import cli -from fimfarchive.commands import RootCommand - - -if __name__ == '__main__': - cmd = RootCommand() - code = cmd(*sys.argv[1:]) - exit(code=code) +cli() diff --git a/fimfarchive/commands/__init__.py b/fimfarchive/commands/__init__.py index 47e813d..dc86008 100644 --- a/fimfarchive/commands/__init__.py +++ b/fimfarchive/commands/__init__.py @@ -5,7 +5,7 @@ # # Fimfarchive, preserves stories from Fimfiction. -# Copyright (C) 2020 Joakim Soderlund +# Copyright (C) 2024 Joakim Soderlund # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,6 +22,9 @@ # +from sys import argv +from typing import NoReturn + from .base import Command from .build import BuildCommand from .root import RootCommand @@ -29,8 +32,15 @@ __all__ = ( + 'cli', 'Command', 'RootCommand', 'BuildCommand', 'UpdateCommand', ) + + +def cli() -> NoReturn: + cmd = RootCommand() + code = cmd(*argv[1:]) + exit(code=code) diff --git a/pyproject.toml b/pyproject.toml index 124f867..b4bc666 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,9 @@ dev-dependencies = [ "types-tqdm", ] +[project.scripts] +fimfarchive = "fimfarchive.commands:cli" + [tool.uv.sources.jsonapi-client] git = "https://github.com/JockeTF/jsonapi-client.git"