From 6c05c1085d9cdd58c432d20f28494bf244049a0e Mon Sep 17 00:00:00 2001 From: finswimmer Date: Wed, 6 Nov 2024 14:25:51 +0100 Subject: [PATCH] feat(cli)!: rename --directory to --project --- src/poetry/console/application.py | 13 +++++-------- src/poetry/console/commands/init.py | 8 +++----- src/poetry/console/commands/new.py | 4 ++-- tests/console/commands/test_build.py | 2 +- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/poetry/console/application.py b/src/poetry/console/application.py index c5c1348d885..1d20a21a052 100644 --- a/src/poetry/console/application.py +++ b/src/poetry/console/application.py @@ -360,13 +360,10 @@ def _default_definition(self) -> Definition: definition.add_option( Option( - "--directory", - "-C", + "--project", + "-P", flag=False, - description=( - "The working directory for the Poetry command (defaults to the" - " current working directory)." - ), + description=("Run the command in the given project directory."), ) ) @@ -374,8 +371,8 @@ def _default_definition(self) -> Definition: @cached_property def _directory(self) -> Path: - if self._io and self._io.input.option("directory"): - return Path(self._io.input.option("directory")).absolute() + if self._io and self._io.input.option("project"): + return Path(self._io.input.option("project")).absolute() return Path.cwd() diff --git a/src/poetry/console/commands/init.py b/src/poetry/console/commands/init.py index b1244965fbf..b27357a2951 100644 --- a/src/poetry/console/commands/init.py +++ b/src/poetry/console/commands/init.py @@ -74,12 +74,10 @@ def handle(self) -> int: project_path = Path.cwd() - if self.io.input.option("directory"): - project_path = Path(self.io.input.option("directory")) + if self.io.input.option("project"): + project_path = Path(self.io.input.option("project")) if not project_path.exists() or not project_path.is_dir(): - self.line_error( - "The --directory path is not a directory." - ) + self.line_error("The --project path is not a directory.") return 1 return self._init_pyproject(project_path=project_path) diff --git a/src/poetry/console/commands/new.py b/src/poetry/console/commands/new.py index bb0fefad961..d1083216329 100644 --- a/src/poetry/console/commands/new.py +++ b/src/poetry/console/commands/new.py @@ -54,9 +54,9 @@ class NewCommand(InitCommand): def handle(self) -> int: from pathlib import Path - if self.io.input.option("directory"): + if self.io.input.option("project"): self.line_error( - "--directory only makes sense with existing projects, and will" + "--project only makes sense with existing projects, and will" " be ignored. You should consider the option --path instead." ) diff --git a/tests/console/commands/test_build.py b/tests/console/commands/test_build.py index 3d17d030b3a..9fc985a0545 100644 --- a/tests/console/commands/test_build.py +++ b/tests/console/commands/test_build.py @@ -206,7 +206,7 @@ def test_build_relative_directory_src_layout( # initializes Poetry before passing the directory. app = Application() tester = ApplicationTester(app) - tester.execute("build --directory .") + tester.execute("build --project .") build_dir = tmp_project_path / "dist"