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 PrintCommand} is a command which prints out a string when it is initialized, and then
009 * immediately finishes. It is useful if you want a {@link CommandGroup} to print out a string when
010 * it reaches a certain point.
011 */
012public class PrintCommand extends InstantCommand {
013  /** The message to print out. */
014  private final String m_message;
015
016  /**
017   * Instantiates a {@link PrintCommand} which will print the given message when it is run.
018   *
019   * @param message the message to print
020   */
021  public PrintCommand(String message) {
022    super("Print(\"" + message + "\"");
023    m_message = message;
024  }
025
026  @Override
027  protected void initialize() {
028    System.out.println(m_message);
029  }
030}