01: /*
02: * This is free software, licensed under the Gnu Public License (GPL)
03: * get a copy from <http://www.gnu.org/licenses/gpl.html>
04: * $Id: EchoCommand.java,v 1.7 2004/01/28 09:25:48 hzeller Exp $
05: * author: Henner Zeller <H.Zeller@acm.org>
06: */
07: package henplus.commands;
08:
09: import henplus.HenPlus;
10: import henplus.SQLSession;
11: import henplus.AbstractCommand;
12:
13: /**
14: * document me.
15: */
16: public final class EchoCommand extends AbstractCommand {
17: /**
18: * returns the command-strings this command can handle.
19: */
20: public String[] getCommandList() {
21: return new String[] { "echo", "prompt" };
22: }
23:
24: public boolean requiresValidSession(String cmd) {
25: return false;
26: }
27:
28: /**
29: * execute the command given.
30: */
31: public int execute(SQLSession currentSession, String cmd,
32: String param) {
33: String outStr = param.trim();
34: HenPlus.out().println(stripQuotes(outStr));
35: return SUCCESS;
36: }
37:
38: private String stripQuotes(String value) {
39: if (value.startsWith("\"") && value.endsWith("\"")) {
40: value = value.substring(1, value.length() - 1);
41: } else if (value.startsWith("\'") && value.endsWith("\'")) {
42: value = value.substring(1, value.length() - 1);
43: }
44: return value;
45: }
46:
47: /**
48: * return a descriptive string.
49: */
50: public String getShortDescription() {
51: return "echo argument";
52: }
53:
54: public String getSynopsis(String cmd) {
55: return cmd + " <whatever>";
56: }
57:
58: public String getLongDescription(String cmd) {
59: String dsc;
60: dsc = "\tjust echo the string given.";
61: return dsc;
62: }
63: }
64:
65: /*
66: * Local variables:
67: * c-basic-offset: 4
68: * compile-command: "ant -emacs -find build.xml"
69: * End:
70: */
|