001/*----------------------------------------------------------------------------*/
002/* Copyright (c) 2008-2018 FIRST. 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   * The command to fork.
017   */
018  private Command m_commandToFork;
019
020  /**
021   * Instantiates a {@link StartCommand} which will start the given command whenever its {@link
022   * Command#initialize() initialize()} is called.
023   *
024   * @param commandToStart the {@link Command} to start
025   */
026  public StartCommand(Command commandToStart) {
027    super("Start(" + commandToStart + ")");
028    m_commandToFork = commandToStart;
029  }
030
031  protected void initialize() {
032    m_commandToFork.start();
033  }
034}