[commands] Add StartRun command factory (#6572)

This commit is contained in:
Tim Winters
2024-05-03 15:40:13 -04:00
committed by GitHub
parent e172aa66f7
commit bad56bcbe8
6 changed files with 60 additions and 0 deletions

View File

@@ -86,6 +86,18 @@ CommandPtr StartEnd(std::function<void()> start, std::function<void()> end,
CommandPtr RunEnd(std::function<void()> run, std::function<void()> end,
Requirements requirements = {});
/**
* Constructs a command that runs an action once, and then runs an action every
* iteration until interrupted.
*
* @param start the action to run on start
* @param run the action to run every iteration
* @param requirements subsystems the action requires
*/
[[nodiscard]]
CommandPtr StartRun(std::function<void()> start, std::function<void()> run,
Requirements requirements = {});
/**
* Constructs a command that prints a message and finishes.
*

View File

@@ -159,6 +159,16 @@ class Subsystem {
[[nodiscard]]
CommandPtr RunEnd(std::function<void()> run, std::function<void()> end);
/**
* Constructs a command that runs an action once, and then runs an action
* every iteration until interrupted. Requires this subsystem.
*
* @param start the action to run on start
* @param run the action to run every iteration
*/
[[nodiscard]]
CommandPtr StartRun(std::function<void()> start, std::function<void()> run);
/**
* Constructs a DeferredCommand with the provided supplier. This subsystem is
* added as a requirement.