From 4c9c321608d31e037f234aa2f845d4a838e434c6 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 1 Jul 2024 11:21:34 -0500 Subject: [PATCH] feat: migrate all commands to use `typer` framework --- pyproject.toml | 4 ++-- rattail_tutorial/commands.py | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f2524b2..6f7184c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ dependencies = [ "furo", "invoke", "psycopg2", - "rattail[auth,db,bouncer]", + "rattail[db,bouncer]", "Sphinx", "Tailbone", "tox", @@ -35,7 +35,7 @@ dependencies = [ [project.scripts] -rattail_tutorial = "rattail_tutorial.commands:main" +rattail_tutorial = "rattail_tutorial.commands:rattail_tutorial_typer" [project.entry-points."paste.app_factory"] diff --git a/rattail_tutorial/commands.py b/rattail_tutorial/commands.py index 78e2dd5..6bca8f8 100644 --- a/rattail_tutorial/commands.py +++ b/rattail_tutorial/commands.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2019 Lance Edgar +# Copyright © 2010-2024 Lance Edgar # # This file is part of Rattail. # @@ -26,11 +26,29 @@ Rattail Tutorial commands import sys -from rattail import commands +import typer +from rattail import commands +from rattail.commands.typer import make_typer from rattail_tutorial import __version__ +rattail_tutorial_typer = make_typer( + name='rattail_tutorial', + help="Rattail Tutorial (custom Rattail system)" +) + + +@rattail_tutorial_typer.command() +def hello( + ctx: typer.Context, +): + """ + The requisite 'hello world' example + """ + sys.stdout.write("hello world!\n") + + def main(*args): """ Main entry point for Rattail Tutorial command system