Skip to content

Commit

Permalink
Fix prompting for multivalue options on config
Browse files Browse the repository at this point in the history
Interactive config generation did not allow to specify no headers.

fixes pulp#1008
  • Loading branch information
mdellweg committed Jul 10, 2024
1 parent 4e378ab commit 0b73cda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/1008.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the interactive config generation in the face of options allowing multiple values.
14 changes: 10 additions & 4 deletions pulp_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,17 @@ def _check_location(location: str) -> None:
def prompt_config_option(name: str) -> t.Any:
"""Find the option from the root command and prompt."""
option = next(p for p in ctx.command.params if p.name == name)
if isinstance(option, click.Option) and option.help:
help = option.help
if option.multiple:
assert option.type == click.types.STRING
assert option.default is None
result = []
value = click.prompt(f"{name} (end with an empty line)", default="", type=option.type)
while value:
result.append(value)
value = click.prompt(f"{name} (continued)", default="", type=option.type)
return result
else:
help = name
return click.prompt(help, default=(option.default), type=option.type)
return click.prompt(name, default=option.default, type=option.type)

settings: t.MutableMapping[str, t.Any] = kwargs
if not settings["plugins"]:
Expand Down

0 comments on commit 0b73cda

Please sign in to comment.