use.py (poetry-1.1.15) | : | use.py (poetry-1.2.0) | ||
---|---|---|---|---|
from cleo import argument | from __future__ import annotations | |||
from ..command import Command | from cleo.helpers import argument | |||
class EnvUseCommand(Command): | from poetry.console.commands.command import Command | |||
name = "use" | class EnvUseCommand(Command): | |||
name = "env use" | ||||
description = "Activates or creates a new virtualenv for the current project ." | description = "Activates or creates a new virtualenv for the current project ." | |||
arguments = [argument("python", "The python executable to use.")] | arguments = [argument("python", "The python executable to use.")] | |||
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) | |||
if self.argument("python") == "system": | if self.argument("python") == "system": | |||
manager.deactivate(self._io) | manager.deactivate(self.io) | |||
return 0 | ||||
return | env = manager.activate(self.argument("python"), self.io) | |||
env = manager.activate(self.argument("python"), self._io) | self.line(f"Using virtualenv: <comment>{env.path}</>") | |||
self.line("Using virtualenv: <comment>{}</>".format(env.path)) | return 0 | |||
End of changes. 9 change blocks. | ||||
8 lines changed or deleted | 11 lines changed or added |