@Override
	public void run() {
		try {
			for (String line; (line = readLine()) != null; ) {
				write(String.format("%s\t\t%s> %s%n", DATE_FORMAT.get().format(new Date()), name, line).getBytes());
				Object result;
				try {
					result = invoke(line);
				} catch (Throwable throwable) {
					ByteArrayOutputStream str = new ByteArrayOutputStream(1024);
					throwable.printStackTrace(new PrintStream(str, true));
					result = str.toString();
				}
				if (result != null) {
					writeLine(String.valueOf(result));
				}
			}
		} catch (IOException e) {
			try {
				writeLine("Shell closed");
			} catch (IOException ex) {
				System.out.println(ex.getClass().getName() + ": " + ex.getMessage());
			}
		}
	}