Skip to content

Commit

Permalink
feat: Addition of global text to ui when -g flag is used (#2952)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElayGelbart committed Jun 19, 2024
1 parent 4660b9d commit 38ccc68
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/pdm/cli/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def do_add(
requirements[key] = r
if requirements:
project.core.ui.echo(
f"Adding packages to [primary]{group}[/] "
f"Adding {'[bold]global[/] ' if project.is_global else ''}packages to [primary]{group}[/] "
f"{'dev-' if selection.dev else ''}dependencies: "
+ ", ".join(f"[req]{r.as_line()}[/]" for r in requirements.values())
)
Expand Down
6 changes: 3 additions & 3 deletions src/pdm/cli/commands/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def handle(self, project: Project, options: argparse.Namespace) -> None:
f"[primary]{key}[/]:"
for key in [
"PDM version",
"Python Interpreter",
"Project Root",
"Local Packages",
f"{'Global ' if project.is_global else ''}Python Interpreter",
f"{'Global ' if project.is_global else ''}Project Root",
f"{'Global ' if project.is_global else ''}Local Packages",
]
],
[
Expand Down
2 changes: 1 addition & 1 deletion src/pdm/cli/commands/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def do_remove(

deps, setter = project.use_pyproject_dependencies(group, selection.dev or False)
project.core.ui.echo(
f"Removing packages from [primary]{group}[/] "
f"Removing {'[bold]global[/] ' if project.is_global else ''}packages from [primary]{group}[/] "
f"{'dev-' if selection.dev else ''}dependencies: " + ", ".join(f"[req]{name}[/]" for name in packages)
)
with cd(project.root):
Expand Down
4 changes: 3 additions & 1 deletion src/pdm/cli/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def do_update(
matched_req.prerelease = prerelease
updated_deps[group][normalized_name] = matched_req
tracked_names.update(chain.from_iterable(updated_deps.values()))
project.core.ui.echo("Updating packages: {}.".format(", ".join(f"[req]{v}[/]" for v in tracked_names)))
project.core.ui.echo(
f"Updating {'[bold]global[/] ' if project.is_global else ''}packages: {', '.join(f'[req]{v}[/]' for v in tracked_names)}."
)
if unconstrained:
for deps in updated_deps.values():
for dep in deps.values():
Expand Down
6 changes: 4 additions & 2 deletions src/pdm/cli/commands/use.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def version_matcher(py_version: PythonInfo) -> bool:
if first or len(found_interpreters) == 1:
return found_interpreters[0]

project.core.ui.echo("Please enter the Python interpreter to use")
project.core.ui.echo(
f"Please enter the {'[bold]Global[/] ' if project.is_global else ''}Python interpreter to use"
)
for i, py_version in enumerate(found_interpreters):
project.core.ui.echo(
f"{i:>2}. [success]{py_version.implementation}@{py_version.identifier}[/] ({py_version.path!s})"
Expand Down Expand Up @@ -135,7 +137,7 @@ def do_use(
saved_python = project._saved_python
old_python = PythonInfo.from_path(saved_python) if saved_python else None
project.core.ui.echo(
f"Using Python interpreter: [success]{selected_python.path!s}[/] ({selected_python_identifier})"
f"Using {'[bold]Global[/] ' if project.is_global else ''}Python interpreter: [success]{selected_python.path!s}[/] ({selected_python_identifier})"
)
project.python = selected_python
if project.environment.is_local:
Expand Down

0 comments on commit 38ccc68

Please sign in to comment.