Migrate the trainwreck commands to use typer

This commit is contained in:
Lance Edgar 2024-05-15 20:49:14 -05:00
parent 76b183676d
commit 98e8e8128d
2 changed files with 21 additions and 9 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2024 Lance Edgar
#
# This file is part of Rattail.
#
@ -21,16 +21,28 @@
#
################################################################################
"""
Rattail Commands
Trainwreck Commands
"""
from rattail import commands
import typer
from rattail.trainwreck.commands import trainwreck_typer
from rattail.commands.typer import importer_command, typer_get_runas_user
from rattail.commands.importing import ImportCommandHandler
class ImportCore(commands.ImportSubcommand):
@trainwreck_typer.command()
@importer_command
def import_corepos(
ctx: typer.Context,
**kwargs
):
"""
Import data from CORE-POS "trans" DB
"""
name = 'import-corepos'
description = __doc__.strip()
handler_key = 'to_trainwreck.from_corepos_db_office_trans.import'
config = ctx.parent.rattail_config
progress = ctx.parent.rattail_progress
handler = ImportCommandHandler(
config, import_handler_key='to_trainwreck.from_corepos_db_office_trans.import')
kwargs['user'] = typer_get_runas_user(ctx)
handler.run(kwargs, progress=progress)

View file

@ -78,5 +78,5 @@ rattail.importing =
rattail.providers =
rattail_corepos = rattail_corepos.app:CoreProvider
trainwreck.subcommands =
import-corepos = rattail_corepos.trainwreck.commands:ImportCore
trainwreck.typer_imports =
rattail_corepos = rattail_corepos.trainwreck.commands