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.wpilibj.command; 006 007/** 008 * A {@link StartCommand} will call the {@link Command#start() start()} method of another command 009 * when it is initialized and will finish immediately. 010 */ 011public class StartCommand extends InstantCommand { 012 /** The command to fork. */ 013 private final Command m_commandToFork; 014 015 /** 016 * Instantiates a {@link StartCommand} which will start the given command whenever its {@link 017 * Command#initialize() initialize()} is called. 018 * 019 * @param commandToStart the {@link Command} to start 020 */ 021 public StartCommand(Command commandToStart) { 022 super("Start(" + commandToStart + ")"); 023 m_commandToFork = commandToStart; 024 } 025 026 @Override 027 protected void initialize() { 028 m_commandToFork.start(); 029 } 030}