fredrik-corneliusson / click-web

Serve click scripts over the web
MIT License
265 stars 17 forks source link

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

Open Declow opened 1 month ago

Declow commented 1 month ago

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
fredrik-corneliusson commented 1 month ago

Thanks for the information! Will be glad to add it to the readme, or a separate README_TYPER that is linked from the README to keep it clean an simple to digest. Do you have an Typer example that I can add?

Declow commented 1 month ago

I could write one for this purpose. Do you have any specifics on how much you would like it to cover or just have it be a basic example of a single command with an argument or two?

fredrik-corneliusson commented 1 month ago

Hi, not really any special requests from me. I suspect that Typer only supports a subset of click so a simple example would be enough.