-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbrowse.py
28 lines (24 loc) · 834 Bytes
/
browse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import typer
from usethis._config import offline_opt, quiet_opt, usethis_config
from usethis._console import err_print
from usethis._core.browse import browse_pypi
from usethis.errors import UsethisError
app = typer.Typer(
help="Visit important project-related web pages.", add_completion=False
)
@app.command(help="Visit the PyPI project page for a package.")
def pypi(
package: str,
*,
browser: bool = typer.Option(
False, "--browser", help="Open the URL in the default web browser."
),
offline: bool = offline_opt,
quiet: bool = quiet_opt,
) -> None:
with usethis_config.set(offline=offline, quiet=quiet):
try:
browse_pypi(package=package, browser=browser)
except UsethisError as err:
err_print(err)
raise typer.Exit(code=1) from None