list.py (poetry-1.1.15) | : | list.py (poetry-1.2.0) | ||
---|---|---|---|---|
from cleo import option | from __future__ import annotations | |||
from ..command import Command | from cleo.helpers import option | |||
class EnvListCommand(Command): | from poetry.console.commands.command import Command | |||
name = "list" | class EnvListCommand(Command): | |||
name = "env list" | ||||
description = "Lists all virtualenvs associated with the current project." | description = "Lists all virtualenvs associated with the current project." | |||
options = [option("full-path", None, "Output the full paths of the virtualen vs.")] | options = [option("full-path", None, "Output the full paths of the virtualen vs.")] | |||
def handle(self): | def handle(self) -> int: | |||
from poetry.utils.env import EnvManager | from poetry.utils.env import EnvManager | |||
manager = EnvManager(self.poetry) | manager = EnvManager(self.poetry) | |||
current_env = manager.get() | current_env = manager.get() | |||
for venv in manager.list(): | for venv in manager.list(): | |||
name = venv.path.name | name = venv.path.name | |||
if self.option("full-path"): | if self.option("full-path"): | |||
name = str(venv.path) | name = str(venv.path) | |||
if venv == current_env: | if venv == current_env: | |||
self.line("<info>{} (Activated)</info>".format(name)) | self.line(f"<info>{name} (Activated)</info>") | |||
continue | continue | |||
self.line(name) | self.line(name) | |||
return 0 | ||||
End of changes. 7 change blocks. | ||||
6 lines changed or deleted | 7 lines changed or added |