1 package org.ibex.xt.shell;
3 import java.io.IOException;
5 public abstract class Env {
6 /** Current JS path using '.' as a seperator. */
7 public String path = "";
9 public Command[] commands = new Command[0];
11 /** Returns the command matching the given name. */
12 public Command command(String name) {
13 for (int i=0; i < commands.length; i++)
14 if (commands[i].name().equals(name)) return commands[i];
18 /** Returns a path, based on console-style representation. */
19 public String path(String c) {
20 if (c.equals("") || c.equals(".")) {
22 } else if (c.equals("..")) {
24 c = c.substring(0, c.lastIndexOf('.'));
25 if (c.equals("")) c = ".";
27 if (c.charAt(0) != '.') c = path + "." + c;
28 if (c.length() > 1 && c.charAt(c.length() - 1) == '.')
29 c = c.substring(0, c.length() - 1);
34 public abstract Request.Response send(Request request) throws IOException;