Package org.jboss.fresh.shell.commands

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

package org.jboss.fresh.shell.commands;

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

import java.io.PrintWriter;

// EX OK

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

  /**
   We set the current active project projekt.
   */


  public void process(String exepath, String[] params) throws Exception {
    log.debug("entered");

    if (helpRequested()) {
      PrintWriter out = new PrintWriter(new BufferWriter(getStdOut()));
      out.print("Usage: project [--help] PROJECT_NAME\n");
      out.print("    PROJECT_NAME : the project to be activated. If no PROJECT_NAME is specified the current active project name is displayed.\n");
      out.print("    --help : this help\n");
      out.close();
      log.debug("done");
      return;
    }

    // if parameter is specified set project to that parameter
    if (params.length > 0) {
      getShell().executeAsObject("exec /projects/" + params[0] + "/project-init.rc");
      getShell().setEnvProperty("PROJECT", params[0]);
      // otherwise display the current project
    } else {
      BufferObjectWriter bout = new BufferObjectWriter(getStdOut());
      bout.writeObject(getShell().getEnvProperty("PROJECT"));
      bout.close();
    }

    log.debug("done");
  }
}
TOP

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

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.