Replace corporal commands with typer equivalents

This commit is contained in:
Lance Edgar 2024-05-15 15:10:35 -05:00
parent 5ff8802061
commit 226c8750a3
2 changed files with 21 additions and 34 deletions

View file

@ -1,43 +1,33 @@
# -*- coding: utf-8; -*-
"""
Corporal commands
"""
import sys
import typer
from rattail import commands
from corporal import __version__
from rattail.commands.typer import typer_callback
def main(*args):
"""
Main entry point for Corporal command system
"""
args = list(args or sys.argv[1:])
cmd = Command()
cmd.run(*args)
# nb. this is the top-level command for corporal
corporal_typer = typer.Typer(
callback=typer_callback,
help="Corporal (custom Rattail system)"
)
class Command(commands.Command):
"""
Main command for Corporal
"""
name = 'corporal'
version = __version__
description = "Corporal (custom Rattail system)"
long_description = ''
class Install(commands.InstallSubcommand):
@corporal_typer.command()
def install(
ctx: typer.Context,
):
"""
Install the Corporal 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. `corporal -n install`
app_title = "Corporal"
app_package = 'corporal'
app_eggname = 'Corporal'
app_pypiname = 'Corporal'
config = ctx.parent.rattail_config
handler = InstallHandler(config,
app_title="Corporal",
app_package='corporal',
app_eggname='Corporal',
app_pypiname='Corporal')
handler.run()

View file

@ -40,10 +40,7 @@ include_package_data = True
[options.entry_points]
console_scripts =
corporal = corporal.commands:main
corporal.subcommands =
install = corporal.commands:Install
corporal = corporal.commands:corporal_typer
paste.app_factory =
main = corporal.web.app:main