From f0bcef49595e1b5d65871632278216497e30429c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 16 May 2024 20:57:37 -0500 Subject: [PATCH] Add typer equivalents for `rattail` commands --- rattail_wave/commands.py | 27 ++++++++++++++++++++++++--- setup.cfg | 3 +++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/rattail_wave/commands.py b/rattail_wave/commands.py index 2bcc303..9796ace 100644 --- a/rattail_wave/commands.py +++ b/rattail_wave/commands.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2024 Lance Edgar # # This file is part of Rattail. # @@ -24,10 +24,31 @@ rattail-wave 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 ImportWave(commands.ImportSubcommand): +@rattail_typer.command() +@importer_command +def import_wave( + ctx: typer.Context, + **kwargs +): + """ + Import data to Rattail, from Wave API + """ + config = ctx.parent.rattail_config + progress = ctx.parent.rattail_progress + handler = ImportCommandHandler( + config, import_handler_key='to_rattail.from_wave.import') + kwargs['user'] = typer_get_runas_user(ctx) + handler.run(kwargs, progress=progress) + + +class ImportWave(ImportSubcommand): """ Import data to Rattail, from Wave API """ diff --git a/setup.cfg b/setup.cfg index ab977a8..06d7273 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,6 +35,9 @@ include_package_data = True rattail.subcommands = import-wave = rattail_wave.commands:ImportWave +rattail.typer_imports = + rattail_wave = rattail_wave.commands + rattail.config.extensions = rattail_wave = rattail_wave.config:RattailWaveExtension