Skip to content

Commit

Permalink
cfbs init now promts user whether to use default masterfiles
Browse files Browse the repository at this point in the history
The cfbs init command now promts users whether or not they want to use
the default masterfiles policy framework. If the user says no, they're
promted with which masterfiles they want to add, allowing them to skip
if empty.

Ticket: CFE-3812
Changelog: Title
Signed-off-by: Lars Erik Wik <[email protected]>
  • Loading branch information
larsewi committed Apr 27, 2022
1 parent 5d910cc commit ed85b86
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,26 @@ def init_command(index=None, non_interactive=False) -> int:
print(
"Initialized an empty project called '{}' in '{}'".format(name, cfbs_filename())
)
print("To add your first module, type: cfbs add masterfiles")

"""
The CFBSConfig instance was initally created in main(). Back then
cfbs.json did not exist, thus the instance is empty. By manually deleting
this instance, a new instance will be created loading the now existing
cfbs.json.
"""
CFBSConfig.instance = None

if prompt_user(
"Do you wish to add default masterfiles?",
choices=YES_NO_CHOICES,
default="yes",
) in ("yes", "y"):
to_add = "masterfiles"
else:
to_add = prompt_user("Specify masterfiles module or skip if empty", default="")

if to_add:
return add_command([to_add])

return 0

Expand Down

0 comments on commit ed85b86

Please sign in to comment.