Skip to content

Commit

Permalink
feat: uvx upgrade-all
Browse files Browse the repository at this point in the history
  • Loading branch information
robinvandernoord committed Apr 10, 2024
1 parent 3e14f1b commit 5edc7af
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/uvx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,29 @@ 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,
skip_injected: Annotated[
bool, typer.Option("--skip-injected", help="Don't also upgrade injected packages")
] = False,
no_cache: Annotated[bool, typer.Option("--no-cache", help="Run without `uv` cache")] = False,
):
"""Upgrade all uvx-installed packages."""

for (venv_name, _) in list_packages():
upgrade(
venv_name,
force=force,
skip_injected=skip_injected,
no_cache=no_cache
)


# list
def _list_short(name: str, metadata: Maybe[Metadata]):
rich.print("-", name, metadata.map_or("[red]?[/red]", lambda md: md.installed_version))
Expand Down Expand Up @@ -212,11 +235,6 @@ def runpython(venv: str, ctx: Context):
subprocess.run([python, *ctx.args]) # nosec


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


def add_to_bashrc(text: str, with_comment: bool = True):
"""Add text to ~/.bashrc, usually with a comment (uvx + timestamp)."""
with (Path.home() / ".bashrc").resolve().open("a") as f:
Expand Down

0 comments on commit 5edc7af

Please sign in to comment.