Skip to content

Commit

Permalink
Fix: Declare and use a follow up question to separate contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloEmidio committed Mar 1, 2023
1 parent ce184c0 commit b2f31fe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ def _determine_requirements(
)
question.set_validator(self._validate_package)

follow_up_question = self.create_question(
"\nAdd a package (leave blank to skip):"
)
follow_up_question.set_validator(self._validate_package)

package = self.ask(question)
while package:
constraint = self._parse_requirements([package])[0]
Expand All @@ -303,9 +308,7 @@ def _determine_requirements(
):
self.line(f"Adding <info>{package}</info>")
result.append(constraint)

self.line("")
package = self.ask(question)
package = self.ask(follow_up_question)
continue

canonicalized_name = canonicalize_name(constraint["name"])
Expand Down Expand Up @@ -373,8 +376,7 @@ def _determine_requirements(
result.append(constraint)

if self.io.is_interactive():
self.line("")
package = self.ask(question)
package = self.ask(follow_up_question)

return result

Expand Down

0 comments on commit b2f31fe

Please sign in to comment.