Skip to content

Commit

Permalink
Add validation check for -C/--directory flag argument
Browse files Browse the repository at this point in the history
Also adds information on automatic Poetry project selection based on the working path argument to the associated help string.
  • Loading branch information
Cypher1 committed Nov 17, 2024
1 parent aa73b3a commit 791665d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ def _default_definition(self) -> Definition:
description=(
"The working directory for the Poetry command (defaults to the"
" current working directory)."
" The Poetry project will be selected automatically using this path"
),
)
)
Expand All @@ -371,7 +372,11 @@ 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()
path = Path(self._io.input.option("directory")).absolute()
if not (path / "pyproject.toml").exists():
raise ValueError(f"Could not find a project in directory {path}")
return path

return Path.cwd()


Expand Down

0 comments on commit 791665d

Please sign in to comment.