Skip to content

Commit

Permalink
Default yes-no questions to yes (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-bc authored Aug 16, 2023
1 parent 77aa704 commit 46262cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/fprime/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ def confirm(msg):
"""Ask user for a yes or no input after displaying the given message"""
# Loop "forever" intended
while True:
confirm_input = input(msg)
if confirm_input.lower() in ["y", "yes"]:
confirm_input = input(msg + " (yes/no) [yes]: ")
# Default to yes when no input
if confirm_input.lower() in ["y", "yes", ""]:
return True
if confirm_input.lower() in ["n", "no"]:
return False
Expand Down
4 changes: 2 additions & 2 deletions src/fprime/fbuild/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def run_fbuild_cli(
print(
f"[INFO] {parsed.command.title()} build directory at: {purge_build.build_dir}"
)
if parsed.force or confirm("Purge this directory (yes/no)?"):
if parsed.force or confirm("Purge this directory?"):
purge_build.purge()
install_dir = purge_build.install_dest_exists()
if (
Expand All @@ -81,7 +81,7 @@ def run_fbuild_cli(
f"[INFO] {parsed.command.title()} install directory at: {install_dir}"
)
if parsed.force or confirm(
f"Purge installation directory at {install_dir} (yes/no)?"
f"Purge installation directory at {install_dir} ?"
):
purge_build.purge_install()
else:
Expand Down
4 changes: 2 additions & 2 deletions src/fprime/util/cookiecutter_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def run_impl(build: Build, source_path: Path):
hpp_dest = hpp_files[0]
cpp_dest = common[0] if common else cpp_files[0]

if not confirm("Generate implementation files (yes/no)? "):
if not confirm("Generate implementation files?"):
return False
print(
"Refreshing cache and generating implementation files (ignore 'Stop' CMake warning)..."
Expand Down Expand Up @@ -96,7 +96,7 @@ def add_to_cmake(list_file: Path, comp_path: Path, project_root: Path = None):
return True

if not confirm(
f"Add component {comp_path} to {short_display_path} at end of file (yes/no)? "
f"Add component {comp_path} to {short_display_path} at end of file?"
):
return False

Expand Down

0 comments on commit 46262cb

Please sign in to comment.