Add typer equivalents for rattail commands

This commit is contained in:
Lance Edgar 2024-05-16 21:00:31 -05:00
parent 6450623802
commit cb62c1383c
2 changed files with 47 additions and 4 deletions

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,50 @@
Rattail/WooCommerce Commands Rattail/WooCommerce 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 ExportWooCommerce(commands.ImportSubcommand): @rattail_typer.command()
@importer_command
def export_woocommerce(
ctx: typer.Context,
**kwargs
):
"""
Export data to WooCommerce
"""
config = ctx.parent.rattail_config
progress = ctx.parent.rattail_progress
handler = ImportCommandHandler(
config,
import_handler_spec='rattail_woocommerce.woocommerce.importing.rattail:FromRattailToWooCommerce')
kwargs['user'] = typer_get_runas_user(ctx)
handler.run(kwargs, progress=progress)
@rattail_typer.command()
@importer_command
def import_woocommerce(
ctx: typer.Context,
**kwargs
):
"""
Import data from WooCommerce
"""
config = ctx.parent.rattail_config
progress = ctx.parent.rattail_progress
handler = ImportCommandHandler(
config,
import_handler_spec='rattail_woocommerce.importing.woocommerce:FromWooCommerceToRattail')
kwargs['user'] = typer_get_runas_user(ctx)
handler.run(kwargs, progress=progress)
class ExportWooCommerce(ImportSubcommand):
""" """
Export data to WooCommerce Export data to WooCommerce
""" """
@ -36,7 +76,7 @@ class ExportWooCommerce(commands.ImportSubcommand):
handler_spec = 'rattail_woocommerce.woocommerce.importing.rattail:FromRattailToWooCommerce' handler_spec = 'rattail_woocommerce.woocommerce.importing.rattail:FromRattailToWooCommerce'
class ImportWooCommerce(commands.ImportSubcommand): class ImportWooCommerce(ImportSubcommand):
""" """
Import data from WooCommerce Import data from WooCommerce
""" """

View file

@ -38,3 +38,6 @@ zip_safe = False
rattail.commands = rattail.commands =
export-woocommerce = rattail_woocommerce.commands:ExportWooCommerce export-woocommerce = rattail_woocommerce.commands:ExportWooCommerce
import-woocommerce = rattail_woocommerce.commands:ImportWooCommerce import-woocommerce = rattail_woocommerce.commands:ImportWooCommerce
rattail.typer_imports =
rattail_woocommerce = rattail_woocommerce.commands