Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Declow opened this issue Jul 12, 2024 · 3 comments
Open

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

Declow opened this issue Jul 12, 2024 · 3 comments

Comments

@Declow
Copy link

Declow commented Jul 12, 2024

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
Copy link
Owner

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
Copy link
Author

Declow commented Jul 23, 2024

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants