From b04816b1ef4c6db390c89847082b4dfc2dd09ce6 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 16 May 2024 20:13:01 -0500 Subject: [PATCH] Add typer equivalents for `rattail` commands --- rattail_nationbuilder/commands.py | 27 ++++++++++++++++++++++++--- setup.cfg | 3 +++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/rattail_nationbuilder/commands.py b/rattail_nationbuilder/commands.py index de3456a..ccfb9bc 100644 --- a/rattail_nationbuilder/commands.py +++ b/rattail_nationbuilder/commands.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2023 Lance Edgar +# Copyright © 2010-2024 Lance Edgar # # This file is part of Rattail. # @@ -24,10 +24,31 @@ rattail-nationbuilder commands """ -from rattail import commands +import typer + +from rattail.commands import rattail_typer, ImportSubcommand +from rattail.commands.typer import importer_command, typer_get_runas_user +from rattail.commands.importing import ImportCommandHandler -class ImportNationBuilder(commands.ImportSubcommand): +@rattail_typer.command() +@importer_command +def import_nationbuilder( + ctx: typer.Context, + **kwargs +): + """ + Import data for NationBuilder => Rattail + """ + config = ctx.parent.rattail_config + progress = ctx.parent.rattail_progress + handler = ImportCommandHandler( + config, import_handler_key='to_rattail.from_nationbuilder.import') + kwargs['user'] = typer_get_runas_user(ctx) + handler.run(kwargs, progress=progress) + + +class ImportNationBuilder(ImportSubcommand): """ Import data for NationBuilder => Rattail """ diff --git a/setup.cfg b/setup.cfg index da55360..9dcabe7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,6 +34,9 @@ include_package_data = True rattail.subcommands = import-nationbuilder = rattail_nationbuilder.commands:ImportNationBuilder +rattail.typer_imports = + rattail_nationbuilder = rattail_nationbuilder.commands + rattail.config.extensions = rattail_nationbuilder = rattail_nationbuilder.config:RattailNationBuilderExtension