Add typer equivalents for rattail commands

This commit is contained in:
Lance Edgar 2024-05-16 19:19:24 -05:00
parent d7e840138b
commit 8784579e27
2 changed files with 27 additions and 3 deletions

View file

@ -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-harvest 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 ImportHarvest(commands.ImportSubcommand):
@rattail_typer.command()
@importer_command
def import_harvest(
ctx: typer.Context,
**kwargs
):
"""
Import data to Rattail, from Harvest API
"""
config = ctx.parent.rattail_config
progress = ctx.parent.rattail_progress
handler = ImportCommandHandler(
config, import_handler_key='to_rattail.from_harvest.import')
kwargs['user'] = typer_get_runas_user(ctx)
handler.run(kwargs, progress=progress)
class ImportHarvest(ImportSubcommand):
"""
Import data to Rattail, from Harvest API
"""

View file

@ -35,6 +35,9 @@ include_package_data = True
rattail.subcommands =
import-harvest = rattail_harvest.commands:ImportHarvest
rattail.typer_imports =
rattail_harvest = rattail_harvest.commands
rattail.config.extensions =
rattail_harvest = rattail_harvest.config:RattailHarvestExtension