clan-cli: restructure according to python's module standard

This commit is contained in:
Jörg Thalheim 2023-07-21 11:38:05 +02:00
parent 73dbad0167
commit 0bf3f42812
3 changed files with 8 additions and 9 deletions

View File

@ -8,19 +8,21 @@ try:
except ImportError:
has_argcomplete = False
import clan_admin
from . import admin
# this will be the entrypoint under /bin/clan (see pyproject.toml config)
def clan() -> None:
def main() -> None:
parser = argparse.ArgumentParser(description="cLAN tool")
subparsers = parser.add_subparsers()
# init clan admin
parser_admin = subparsers.add_parser("admin")
clan_admin.make_parser(parser_admin)
admin.register_parser(parser_admin)
if has_argcomplete:
argcomplete.autocomplete(parser)
parser.parse_args()
if len(sys.argv) == 1:
parser.print_help()
if __name__ == "__main__":
main()

View File

@ -70,7 +70,7 @@ def git(args: argparse.Namespace) -> None: # pragma: no cover
)
# takes a (sub)parser and configures it
def make_parser(parser: argparse.ArgumentParser) -> None:
def register_parser(parser: argparse.ArgumentParser) -> None:
parser.add_argument(
"-f",
"--folder",

View File

@ -2,14 +2,11 @@
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
include = ["clan.py"]
[project]
name = "clan"
description = "cLAN CLI tool"
dynamic = ["version"]
scripts = {clan = "clan:clan"}
scripts = {clan = "clan_cli:main"}
[tool.pytest.ini_options]
addopts = "--cov . --cov-report term --cov-fail-under=100 --no-cov-on-fail"