Skip to content

Commit 5418314

Browse files
committed
recommended changes
1 parent 8480f6e commit 5418314

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

commands2/cmd.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,23 @@ def select(
165165
"""
166166
return SelectCommand(commands, selector)
167167

168+
def fork(
169+
*commands: Command
170+
) -> Command:
171+
"""
172+
Create a command to run "forked" by wrapping the provided commands in a ScheduleCommand. Use this for
173+
"forking off" from command compositions when the user does not wish to extend the command's
174+
requirements to the entire command composition. Note that if run from a composition, the
175+
composition will not know about the status of the scheduled commands, and will treat this
176+
command as finishing instantly. Multiple commmands can be added to this and will be schedule in order.,
177+
see the `WPILib docs <https://docs.wpilib.org/en/stable/docs/software/commandbased/command-compositions.html#scheduling-other-commands>`_ for a full explanation.
178+
179+
:param commands: commands to schedule in order
180+
:returns: the command
181+
"""
182+
from .schedulecommand import ScheduleCommand
183+
return ScheduleCommand(commands)
184+
168185

169186
def sequence(*commands: Command) -> Command:
170187
"""

commands2/command.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .parallelcommandgroup import ParallelCommandGroup
1919
from .repeatcommand import RepeatCommand
2020
from .proxycommand import ProxyCommand
21+
from .schedulecommand import ScheduleCommand
2122
from .conditionalcommand import ConditionalCommand
2223
from .wrappercommand import WrapperCommand
2324

@@ -384,21 +385,20 @@ def asProxy(self) -> ProxyCommand:
384385

385386
return ProxyCommand(self)
386387

387-
def fork(self, *commands: Command) -> ProxyCommand:
388+
def fork(self, *commands: Command) -> ScheduleCommand:
388389
"""
389390
Decorates this command to run "forked" by wrapping it in a ScheduleCommand. Use this for
390391
"forking off" from command compositions when the user does not wish to extend the command's
391392
requirements to the entire command composition. Note that if run from a composition, the
392393
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.
394+
command as finishing instantly., see the `WPILib docs <https://docs.wpilib.org/en/stable/docs/software/commandbased/command-compositions.html#scheduling-other-commands>`_ for a full explanation.
395395
396396
:param other: other commands to schedule along with this one. This command is scheduled first.
397397
:returns: the decorated command
398398
"""
399399
from .schedulecommand import ScheduleCommand
400400

401-
return ScheduleCommand(self, [self] + commands)
401+
return ScheduleCommand(self)
402402

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

0 commit comments

Comments
 (0)