Skip to content

Commit

Permalink
fix: switch to questionary
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Aug 29, 2024
1 parent 0ecb833 commit 603d55b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 37 deletions.
50 changes: 19 additions & 31 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ dependencies = [
"tomli-w",
"httpx-ws>=0.6.0",
"aiosqlite>=0.20.0",
"InquirerPy>=0.3.4",
"uv",
"questionary>=2.0.1",
]
dynamic = ["version"]
[project.urls]
Expand Down
12 changes: 7 additions & 5 deletions src/bentoml_cli/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import click
import click_option_group as cog
import rich
from InquirerPy import inquirer
from rich.prompt import Confirm

from bentoml._internal.cloud.client import RestApiClient
from bentoml._internal.cloud.config import CloudClientConfig
Expand Down Expand Up @@ -50,8 +48,11 @@ def cloud_command():
)
def login(endpoint: str, api_token: str) -> None: # type: ignore (not accessed)
"""Login to BentoCloud."""
import questionary
from rich.prompt import Confirm

if not api_token:
choice = inquirer.select(
choice = questionary.select(
message="How would you like to authenticate BentoML CLI? [Use arrows to move]",
choices=[
{
Expand All @@ -60,7 +61,7 @@ def login(endpoint: str, api_token: str) -> None: # type: ignore (not accessed)
},
{"name": "Paste an existing API token", "value": "paste"},
],
).execute()
).ask()

if choice == "create":
with contextlib.ExitStack() as port_stack:
Expand All @@ -73,7 +74,8 @@ def login(endpoint: str, api_token: str) -> None: # type: ignore (not accessed)
encodedCallback = urllib.parse.quote(callback_server.callback_url)
authURL = f"{baseURL}?callback={encodedCallback}"
if Confirm.ask(
f"Please Enter Y or N to open [blue]{authURL}[/] in your browser..."
f"Would you like to open [blue]{authURL}[/] in your browser?",
default=True,
):
if webbrowser.open_new_tab(authURL):
rich.print(f"✅ Opened [blue]{authURL}[/] in your web browser.")
Expand Down

0 comments on commit 603d55b

Please sign in to comment.