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 Corporal commands
""" """
import sys import typer
from rattail import commands from rattail.commands.typer import typer_callback
from corporal import __version__
def main(*args): # nb. this is the top-level command for corporal
""" corporal_typer = typer.Typer(
Main entry point for Corporal command system callback=typer_callback,
""" help="Corporal (custom Rattail system)"
args = list(args or sys.argv[1:]) )
cmd = Command()
cmd.run(*args)
class Command(commands.Command): @corporal_typer.command()
""" def install(
Main command for Corporal ctx: typer.Context,
""" ):
name = 'corporal'
version = __version__
description = "Corporal (custom Rattail system)"
long_description = ''
class Install(commands.InstallSubcommand):
""" """
Install the Corporal app Install the Corporal app
""" """
name = 'install' from rattail.install import InstallHandler
description = __doc__.strip()
# nb. these must be explicitly set b/c config is not available config = ctx.parent.rattail_config
# when running normally, e.g. `corporal -n install` handler = InstallHandler(config,
app_title = "Corporal" app_title="Corporal",
app_package = 'corporal' app_package='corporal',
app_eggname = 'Corporal' app_eggname='Corporal',
app_pypiname = 'Corporal' app_pypiname='Corporal')
handler.run()

View file

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