click-web icon indicating copy to clipboard operation
click-web copied to clipboard

Update README and add example on how to use typer with click-web

Open Declow opened this issue 7 months ago • 3 comments

Hey!

I just found this project and really like the idea. Now I already had a tool written in typer and not click. However typer is based on click so it is possible to use this tool with typer!

It would be nice to update the README and inform users that they can use typer with this tool and maybe add an example in the repo. The get_command function from typer generates a click command group and the only requirement to make it work with click-web is to set the name variable.

Take your Typer() instance and do the following

commands.py

import typer

typer_app = typer.Typer()

main.py

from click_web import create_click_web_app
import commands
import typer

typer_app = typer.Typer()

cmd = typer.main.get_command(commands.typer_app)
cmd.name = "cli"
app = create_click_web_app(commands, cmd)

start.sh

export FLASK_ENV=development
export FLASK_APP=app.py
flask run

Declow avatar Jul 12 '24 11:07 Declow