Package org.jboss.fresh.shell.commands

Source Code of org.jboss.fresh.shell.commands.EchoExe

package org.jboss.fresh.shell.commands;

import org.jboss.fresh.io.BufferWriter;
import org.jboss.fresh.shell.AbstractExecutable;

import java.io.BufferedWriter;
import java.io.PrintWriter;

// EX OK

public class EchoExe extends AbstractExecutable {
  private static transient org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(EchoExe.class);

  /**
   Sents the parameters we specified to the standard out Buffer, with a " " string between each parameter.
   */
  public void process(String exepath, String[] params) {
    log.debug("entered");
    // echo displays parameters to out just as it gets them making spaces in between

    if (helpRequested()) {
      PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
      out.print("Usage: echo [--help] [params]\n");
      out.print("      params : params to be sent to the pipeline with spaces in between each parameter.\n");
      out.print("      --help : this help\n");
      out.flush();
      log.debug("done");
      return;
    }

    PrintWriter pout = new PrintWriter(new BufferedWriter(new BufferWriter(getStdOut())));
    for (int i = 0; i < params.length; i++) {
      if (i > 0)
        pout.print(" ");
      pout.print(params[i]);
    }
    pout.flush();
    log.debug("done");
  }
}
TOP

Related Classes of org.jboss.fresh.shell.commands.EchoExe

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.