Skip to content

Commit 7f326c1

Browse files
committed
when no timeout is set for prompt_user, retry until space is pressed
this is generally the desired behavior, if timeouts or alternate flows are needed, a timeout can be added and the return code can be used Signed-off-by: Zen <[email protected]>
1 parent ac9b69f commit 7f326c1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/ugrd/base/base.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "desultory"
2-
__version__ = "7.0.0"
2+
__version__ = "7.1.0"
33

44
from pathlib import Path
55
from shutil import which
@@ -252,6 +252,8 @@ def prompt_user(self) -> list[str]:
252252
The first argument is the prompt message.
253253
The second argument is the timeout in seconds.
254254
255+
If the timeout is not set, or set to zero, loops wait_for_space until space is pressed.
256+
255257
if plymouth is running, run 'plymouth display-message --text="$prompt" instead of echo.
256258
"""
257259
output = ['prompt=${1:-"Press space to continue."}']
@@ -266,6 +268,12 @@ def prompt_user(self) -> list[str]:
266268
else:
267269
output += [r'printf "\033[1;35m *\033[0m %s\n" "$prompt"']
268270
output += [
271+
'if [ -z "$2" ] || [ "$2" -eq 0 ]; then',
272+
' while ! wait_for_space; do',
273+
' ewarn "Invalid input, press space to continue."',
274+
' done',
275+
' return 0',
276+
'fi',
269277
'wait_for_space "$2"',
270278
'return "$?"',
271279
]

0 commit comments

Comments
 (0)