Skip to content

Commit

Permalink
fix: work in progress on self-update
Browse files Browse the repository at this point in the history
  • Loading branch information
robinvandernoord committed Apr 10, 2024
1 parent 8c20be4 commit 56dec48
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/uvx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .__about__ import __version__
from ._cli_support import State
from ._maybe import Maybe
from ._python import _python_in_venv, _uv
from ._python import _python_in_venv, _uv, _pip
from .core import (
as_virtualenv,
format_bools,
Expand Down Expand Up @@ -128,11 +128,6 @@ def inject(into: str, package_specs: list[str]):
)


# todo:
# self-upgrade (uv and uvx)
# upgrade-all


@app.command()
def upgrade_all(
force: Annotated[bool, typer.Option("-f", "--force", help="Ignore previous version constraint")] = False,
Expand All @@ -146,6 +141,20 @@ def upgrade_all(
upgrade(venv_name, force=force, skip_injected=skip_injected, no_cache=no_cache)


@app.command()
def self_update(
with_uv: Annotated[bool, typer.Option("--with-uv/--without-uv", '-w/-W')] = True,
):
# if in venv and uv available -> upgrade via uv
# else: upgrade via pip
if os.getenv("VIRTUAL_ENV"):
print(_uv)
else:
print(_pip)

print(f'self update {with_uv = }')


# list
def _list_short(name: str, metadata: Maybe[Metadata]):
rich.print("-", name, metadata.map_or("[red]?[/red]", lambda md: md.installed_version))
Expand Down

0 comments on commit 56dec48

Please sign in to comment.