// Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package net.sourceforge.eclipsejetty.starter.console.command; import net.sourceforge.eclipsejetty.starter.console.AbstractCommand; import net.sourceforge.eclipsejetty.starter.console.ConsoleAdapter; import net.sourceforge.eclipsejetty.starter.console.Process; /** * Prints text. * * @author Manfred Hantschel */ public class EchoCommand extends AbstractCommand { public EchoCommand(ConsoleAdapter consoleAdapter) { super(consoleAdapter, "echo", "e"); } /** * {@inheritDoc} * * @see net.sourceforge.eclipsejetty.starter.console.Command#getFormat() */ public String getFormat() { return "{<TEXT>}"; } /** * {@inheritDoc} * * @see net.sourceforge.eclipsejetty.starter.console.Command#getDescription() */ public String getDescription() { return "Prints the text."; } /** * {@inheritDoc} * * @see net.sourceforge.eclipsejetty.starter.console.Command#getOrdinal() */ public int getOrdinal() { return 550; } /** * {@inheritDoc} * * @see net.sourceforge.eclipsejetty.starter.console.Command#execute(java.lang.String, * net.sourceforge.eclipsejetty.starter.console.Process) */ public int execute(String commandName, Process process) throws Exception { StringBuilder builder = new StringBuilder(); String argument; while ((argument = process.args.consumeString()) != null) { if (builder.length() > 0) { builder.append(" "); } builder.append(argument); } process.out.println(builder.toString()); return 0; } /** * {@inheritDoc} * * @see net.sourceforge.eclipsejetty.starter.console.AbstractCommand#getHelpDescription() */ @Override protected String getHelpDescription() { return "Prints the text. May contain ${..} placeholders."; } }