update.py (poetry-1.1.15) | : | update.py (poetry-1.2.0) | ||
---|---|---|---|---|
from cleo import argument | from __future__ import annotations | |||
from cleo import option | ||||
from .installer_command import InstallerCommand | from cleo.helpers import argument | |||
from cleo.helpers import option | ||||
class UpdateCommand(InstallerCommand): | from poetry.console.commands.installer_command import InstallerCommand | |||
class UpdateCommand(InstallerCommand): | ||||
name = "update" | name = "update" | |||
description = ( | description = ( | |||
"Update the dependencies as according to the <comment>pyproject.toml</> file." | "Update the dependencies as according to the <comment>pyproject.toml</> file." | |||
) | ) | |||
arguments = [ | arguments = [ | |||
argument("packages", "The packages to update", optional=True, multiple=T rue) | argument("packages", "The packages to update", optional=True, multiple=T rue) | |||
] | ] | |||
options = [ | options = [ | |||
option("no-dev", None, "Do not update the development dependencies."), | *InstallerCommand._group_dependency_options(), | |||
option( | ||||
"no-dev", | ||||
None, | ||||
"Do not update the development dependencies." | ||||
" (<warning>Deprecated</warning>)", | ||||
), | ||||
option( | option( | |||
"dry-run", | "dry-run", | |||
None, | None, | |||
"Output the operations but do not execute anything " | "Output the operations but do not execute anything " | |||
"(implicitly enables --verbose).", | "(implicitly enables --verbose).", | |||
), | ), | |||
option("lock", None, "Do not perform operations (only update the lockfil e)."), | option("lock", None, "Do not perform operations (only update the lockfil e)."), | |||
] | ] | |||
loggers = ["poetry.repositories.pypi_repository"] | loggers = ["poetry.repositories.pypi_repository"] | |||
def handle(self): | def handle(self) -> int: | |||
packages = self.argument("packages") | packages = self.argument("packages") | |||
self._installer.use_executor( | self.installer.use_executor( | |||
self.poetry.config.get("experimental.new-installer", False) | self.poetry.config.get("experimental.new-installer", False) | |||
) | ) | |||
if packages: | if packages: | |||
self._installer.whitelist({name: "*" for name in packages}) | self.installer.whitelist({name: "*" for name in packages}) | |||
self._installer.dev_mode(not self.option("no-dev")) | self.installer.only_groups(self.activated_groups) | |||
self._installer.dry_run(self.option("dry-run")) | self.installer.dry_run(self.option("dry-run")) | |||
self._installer.execute_operations(not self.option("lock")) | self.installer.execute_operations(not self.option("lock")) | |||
# Force update | # Force update | |||
self._installer.update(True) | self.installer.update(True) | |||
return self._installer.run() | return self.installer.run() | |||
End of changes. 11 change blocks. | ||||
12 lines changed or deleted | 19 lines changed or added |