Skip to content

Commit 44b8709

Browse files
Update cmd.py
1 parent e8cea7f commit 44b8709

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

commands2/cmd.py

+15
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ def startRun(
110110
start, run, lambda interrupt: None, lambda: False, *requirements
111111
)
112112

113+
def startRunEnd(
114+
start: Callable[[], Any], run: Callable[[], Any], end: Callable[[], Any],
115+
*requirements: Subsystem) -> Command:
116+
"""
117+
Constructs a command that runs an action once, and then runs an action every iteration until interrupted,
118+
and then runs a third action.
119+
120+
:param start the action to run on start
121+
:param run the action to run every iteration
122+
:param end the action to run on interrupt
123+
:returns: the command
124+
"""
125+
return FunctionalCommand(
126+
start, run, lambda interrupted: end(), lambda: False, *requirements
127+
)
113128

114129
def print_(message: str) -> Command:
115130
"""

0 commit comments

Comments
 (0)