Skip to content

Commit 8006897

Browse files
authored
Merge pull request #71 from narmstro2020/ScheduleDecorator
[cmd] Add ScheduleCommand decorator
2 parents 81f6129 + 511e7c1 commit 8006897

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: commands2/command.py

+17
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,23 @@ def asProxy(self) -> ProxyCommand:
383383
from .proxycommand import ProxyCommand
384384

385385
return ProxyCommand(self)
386+
387+
def fork(self, *commands: Command) -> ProxyCommand:
388+
"""
389+
Decorates this command to run "forked" by wrapping it in a ScheduleCommand. Use this for
390+
"forking off" from command compositions when the user does not wish to extend the command's
391+
requirements to the entire command composition. Note that if run from a composition, the
392+
composition will not know about the status of the scheduled commands, and will treat this
393+
command as finishing instantly. Commands can be added to this and will be scheduled in order
394+
with this command scheduled first., see the `WPILib docs <https://docs.wpilib.org/en/stable/docs/software/commandbased/command-compositions.html#scheduling-other-commands>`_ for a full explanation.
395+
396+
:param other: other commands to schedule along with this one. This command is scheduled first.
397+
:returns: the decorated command
398+
"""
399+
from .schedulecommand import ScheduleCommand
400+
401+
402+
return ScheduleCommand(self, [self] + commands)
386403

387404
def unless(self, condition: Callable[[], bool]) -> ConditionalCommand:
388405
"""

0 commit comments

Comments
 (0)