Skip to content

Commit

Permalink
cfbs add: Now prompts to add individual modules after user says no to…
Browse files Browse the repository at this point in the history
… add all from URL

Ticket: CFE-4015
Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
  • Loading branch information
olehermanse committed May 28, 2024
1 parent 726a1b5 commit 6f7c7b2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cfbs/cfbs_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def _add_using_url(
remote_config = CFBSJson(path=config_path, url=url, url_commit=url_commit)

provides = remote_config.get_provides()
add_all = True
# URL specified in to_add, but no specific modules => let's add all (with a prompt)
if len(to_add) == 0:
modules = list(provides.values())
Expand All @@ -149,14 +150,24 @@ def _add_using_url(
default="yes",
)
if answer.lower() not in ("y", "yes"):
return
add_all = False
else:
missing = [k for k in to_add if k not in provides]
if missing:
user_error("Missing modules: " + ", ".join(missing))
modules = [provides[k] for k in to_add]

for module in modules:
for i, module in enumerate(modules, start=1):
if not add_all:
answer = prompt_user(
non_interactive=self.non_interactive,
prompt="(%d/%d) Do you want to add '%s'?"
% (i, len(modules), module["name"]),
choices=YES_NO_CHOICES,
default="yes",
)
if answer.lower() not in ("y", "yes"):
continue
self.add_with_dependencies(module, remote_config)

@staticmethod
Expand Down

0 comments on commit 6f7c7b2

Please sign in to comment.