001/*----------------------------------------------------------------------------*/
002/* Copyright (c) FIRST 2008-2017. All Rights Reserved.                        */
003/* Open Source Software - may be modified and shared by FRC teams. The code   */
004/* must be accompanied by the FIRST BSD license file in the root directory of */
005/* the project.                                                               */
006/*----------------------------------------------------------------------------*/
007
008package edu.wpi.first.wpilibj.command;
009
010/**
011 * A {@link StartCommand} will call the {@link Command#start() start()} method of another command
012 * when it is initialized and will finish immediately.
013 */
014public class StartCommand extends InstantCommand {
015
016  /**
017   * The command to fork.
018   */
019  private Command m_commandToFork;
020
021  /**
022   * Instantiates a {@link StartCommand} which will start the given command whenever its {@link
023   * Command#initialize() initialize()} is called.
024   *
025   * @param commandToStart the {@link Command} to start
026   */
027  public StartCommand(Command commandToStart) {
028    super("Start(" + commandToStart + ")");
029    m_commandToFork = commandToStart;
030  }
031
032  protected void initialize() {
033    m_commandToFork.start();
034  }
035}