Migrate commands to use 'typer' framework
This commit is contained in:
parent
8a6933c43e
commit
af1757b66f
|
@ -26,6 +26,7 @@ install_requires =
|
|||
mysql-connector-python
|
||||
psycopg2
|
||||
Tailbone
|
||||
typer
|
||||
|
||||
packages = find:
|
||||
include_package_data = True
|
||||
|
@ -41,7 +42,7 @@ locsms = luckysmores; rattail-luckysmores; tailbone-locsms
|
|||
[options.entry_points]
|
||||
|
||||
console_scripts =
|
||||
theo = theo.commands:main
|
||||
theo = theo.commands:theo_typer
|
||||
|
||||
rattail.config.extensions =
|
||||
theo = theo.config:TheoConfig
|
||||
|
@ -57,6 +58,3 @@ rattail.importing =
|
|||
paste.app_factory =
|
||||
main = theo.web.app:main
|
||||
webapi = theo.web.webapi:main
|
||||
|
||||
theo.subcommands =
|
||||
install = theo.commands:Install
|
||||
|
|
|
@ -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,42 +24,31 @@
|
|||
Theo commands
|
||||
"""
|
||||
|
||||
import sys
|
||||
import typer
|
||||
|
||||
from rattail import commands
|
||||
|
||||
from theo import __version__
|
||||
from rattail.commands.typer import typer_callback
|
||||
|
||||
|
||||
def main(*args):
|
||||
"""
|
||||
Main entry point for Theo command system
|
||||
"""
|
||||
args = list(args or sys.argv[1:])
|
||||
cmd = Command()
|
||||
cmd.run(*args)
|
||||
# nb. this is the top-level command for corporal
|
||||
theo_typer = typer.Typer(
|
||||
callback=typer_callback,
|
||||
help="Theo, the order system"
|
||||
)
|
||||
|
||||
|
||||
class Command(commands.Command):
|
||||
"""
|
||||
Main command for Theo
|
||||
"""
|
||||
name = 'theo'
|
||||
version = __version__
|
||||
description = "Theo, the order system"
|
||||
long_description = ''
|
||||
|
||||
|
||||
class Install(commands.InstallSubcommand):
|
||||
@theo_typer.command()
|
||||
def install(
|
||||
ctx: typer.Context,
|
||||
):
|
||||
"""
|
||||
Install the Theo app
|
||||
"""
|
||||
name = 'install'
|
||||
description = __doc__.strip()
|
||||
from rattail.install import InstallHandler
|
||||
|
||||
# nb. these must be explicitly set b/c config is not available
|
||||
# when running normally, e.g. `theo -n install`
|
||||
app_title = "Theo"
|
||||
app_package = 'theo'
|
||||
app_eggname = 'tailbone_theo'
|
||||
app_pypiname = 'tailbone-theo'
|
||||
config = ctx.parent.rattail_config
|
||||
handler = InstallHandler(config,
|
||||
app_title="Theo",
|
||||
app_package='theo',
|
||||
app_eggname='tailbone_theo',
|
||||
app_pypiname='tailbone-theo')
|
||||
handler.run()
|
||||
|
|
Loading…
Reference in a new issue