@@ -109,7 +109,7 @@ def search_command(terms: List[str]) -> int:
109109 ls_remote ,
110110)
111111from cfbs .git_magic import Result , commit_after_command , git_commit_maybe_prompt
112- from cfbs .prompts import YES_NO_CHOICES , prompt_user
112+ from cfbs .prompts import prompt_user , prompt_user_yesno
113113from cfbs .module import Module , is_module_added_manually
114114from cfbs .masterfiles .generate_release_information import generate_release_information
115115
@@ -199,20 +199,15 @@ def init_command(index=None, masterfiles=None, non_interactive=False) -> int:
199199 is_git = is_git_repo ()
200200 if do_git is None :
201201 if is_git :
202- git_ans = prompt_user (
202+ do_git = prompt_user_yesno (
203203 non_interactive ,
204204 "This is a git repository. Do you want cfbs to make commits to it?" ,
205- choices = YES_NO_CHOICES ,
206- default = "yes" ,
207205 )
208206 else :
209- git_ans = prompt_user (
207+ do_git = prompt_user_yesno (
210208 non_interactive ,
211209 "Do you want cfbs to initialize a git repository and make commits to it?" ,
212- choices = YES_NO_CHOICES ,
213- default = "yes" ,
214210 )
215- do_git = git_ans .lower () in ("yes" , "y" )
216211 else :
217212 assert do_git in ("yes" , "no" )
218213 do_git = True if do_git == "yes" else False
@@ -287,12 +282,10 @@ def init_command(index=None, masterfiles=None, non_interactive=False) -> int:
287282 branch = None
288283 to_add = []
289284 if masterfiles is None :
290- if prompt_user (
285+ if prompt_user_yesno (
291286 non_interactive ,
292287 "Do you wish to build on top of the default policy set, masterfiles? (Recommended)" ,
293- choices = YES_NO_CHOICES ,
294- default = "yes" ,
295- ) in ("yes" , "y" ):
288+ ):
296289 to_add = ["masterfiles" ]
297290 else :
298291 answer = prompt_user (
@@ -477,7 +470,7 @@ def _get_module_by_name(name) -> Union[dict, None]:
477470
478471 def _remove_module_user_prompt (module ):
479472 dependents = _get_dependents (module ["name" ])
480- return prompt_user (
473+ return prompt_user_yesno (
481474 config .non_interactive ,
482475 "Do you wish to remove '%s'?" % module ["name" ]
483476 + (
@@ -486,8 +479,6 @@ def _remove_module_user_prompt(module):
486479 if dependents
487480 else ""
488481 ),
489- choices = YES_NO_CHOICES ,
490- default = "yes" ,
491482 )
492483
493484 def _get_modules_by_url (name ) -> list :
@@ -506,31 +497,28 @@ def _get_modules_by_url(name) -> list:
506497 if not matches :
507498 raise CFBSExitError ("Could not find module with URL '%s'" % name )
508499 for module in matches :
509- answer = _remove_module_user_prompt (module )
510- if answer .lower () in ("yes" , "y" ):
500+ if _remove_module_user_prompt (module ):
511501 print ("Removing module '%s'" % module ["name" ])
512502 modules .remove (module )
513503 msg += "\n - Removed module '%s'" % module ["name" ]
514504 num_removed += 1
515505 else :
516506 module = _get_module_by_name (name )
517507 if module :
518- answer = _remove_module_user_prompt (module )
519- if answer .lower () in ("yes" , "y" ):
508+ if _remove_module_user_prompt (module ):
520509 print ("Removing module '%s'" % name )
521510 modules .remove (module )
522511 msg += "\n - Removed module '%s'" % module ["name" ]
523512 num_removed += 1
524513 else :
525514 print ("Module '%s' not found" % name )
526515 input_path = os .path .join ("." , name , "input.json" )
527- if os .path .isfile (input_path ) and prompt_user (
516+ if os .path .isfile (input_path ) and prompt_user_yesno (
528517 config .non_interactive ,
529518 "Module '%s' has input data '%s'. Do you want to remove it?"
530519 % (name , input_path ),
531- choices = YES_NO_CHOICES ,
532520 default = "no" ,
533- ). lower () in ( "yes" , "y" ) :
521+ ):
534522 rm (input_path )
535523 files .append (input_path )
536524 msg += "\n - Removed input data for module '%s'" % name
@@ -594,13 +582,10 @@ def _someone_needs_me(this) -> bool:
594582 added_by = module ["added_by" ] if "added_by" in module else ""
595583 print ("%s - %s - added by: %s" % (name , description , added_by ))
596584
597- answer = prompt_user (
585+ if prompt_user_yesno (
598586 config .non_interactive ,
599587 "Do you wish to remove these modules?" ,
600- choices = YES_NO_CHOICES ,
601- default = "yes" ,
602- )
603- if answer .lower () in ("yes" , "y" ):
588+ ):
604589 for module in to_remove :
605590 modules .remove (module )
606591 config .save ()
@@ -1144,12 +1129,11 @@ def input_command(args, input_from="cfbs input") -> Result:
11441129
11451130 input_path = os .path .join ("." , module_name , "input.json" )
11461131 if os .path .isfile (input_path ):
1147- if prompt_user (
1132+ if not prompt_user_yesno (
11481133 config .non_interactive ,
11491134 "Input already exists for this module, do you want to overwrite it?" ,
1150- YES_NO_CHOICES ,
1151- "no" ,
1152- ).lower () in ("no" , "n" ):
1135+ default = "no" ,
1136+ ):
11531137 continue
11541138
11551139 input_data = copy .deepcopy (module ["input" ])
0 commit comments