-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from evanmags/main
feat: Add support for Typer
- Loading branch information
Showing
4 changed files
with
130 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import click | ||
|
||
try: | ||
import typer | ||
except ImportError: | ||
raise ImportError( | ||
"The extra `trogon[typer]` is required to enable tui generation from Typer apps." | ||
) | ||
|
||
from trogon.trogon import Trogon | ||
|
||
|
||
def init_tui(app: typer.Typer, name: str | None = None): | ||
def wrapped_tui(): | ||
Trogon( | ||
typer.main.get_group(app), | ||
app_name=name, | ||
click_context=click.get_current_context(), | ||
).run() | ||
|
||
app.command("tui", help="Open Textual TUI.")(wrapped_tui) | ||
|
||
return app |