001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj2.command;
006
007/**
008 * A Command that runs instantly; it will initialize, execute once, and end on the same iteration of
009 * the scheduler. Users can either pass in a Runnable and a set of requirements, or else subclass
010 * this command if desired.
011 *
012 * <p>This class is provided by the NewCommands VendorDep
013 */
014public class InstantCommand extends FunctionalCommand {
015  /**
016   * Creates a new InstantCommand that runs the given Runnable with the given requirements.
017   *
018   * @param toRun the Runnable to run
019   * @param requirements the subsystems required by this command
020   */
021  public InstantCommand(Runnable toRun, Subsystem... requirements) {
022    super(toRun, () -> {}, interrupted -> {}, () -> true, requirements);
023  }
024
025  /**
026   * Creates a new InstantCommand with a Runnable that does nothing. Useful only as a no-arg
027   * constructor to call implicitly from subclass constructors.
028   */
029  public InstantCommand() {
030    this(() -> {});
031  }
032}