From 3ec9660409547c0646e43a7d7b7999541e3cbdf3 Mon Sep 17 00:00:00 2001 From: Julien Date: Fri, 31 Jan 2025 10:05:30 +0100 Subject: [PATCH] docs: add documentation to integrate alchemy commands in an existing group (#378) --- docs/usage/cli.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/usage/cli.rst b/docs/usage/cli.rst index 76730330..b002efcc 100644 --- a/docs/usage/cli.rst +++ b/docs/usage/cli.rst @@ -274,6 +274,32 @@ Here's how to extend the CLI with your own commands: # Add migration commands to your group add_migration_commands(alchemy_group) +Custom Group Integration +~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also integrate Advanced Alchemy's commands into your existing Click group: + +.. code-block:: python + + import click + from advanced_alchemy.cli import add_migration_commands + + @click.group() + def cli(): + """My application CLI.""" + pass + + # Add migration commands to your CLI group + add_migration_commands(cli) + + @cli.command() + def my_command(): + """Custom command in your CLI.""" + pass + + if __name__ == "__main__": + cli() + Typer integration -----------------