From: <cr...@us...> - 2008-11-22 06:47:15
|
Revision: 4713 http://jnode.svn.sourceforge.net/jnode/?rev=4713&view=rev Author: crawley Date: 2008-11-22 06:47:09 +0000 (Sat, 22 Nov 2008) Log Message: ----------- Removing 'old syntax' code Modified Paths: -------------- trunk/shell/descriptors/org.jnode.shell.xml trunk/shell/src/shell/org/jnode/shell/CommandLine.java trunk/shell/src/shell/org/jnode/shell/CommandRunner.java trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/help/Help.java trunk/shell/src/shell/org/jnode/shell/help/HelpFactory.java trunk/shell/src/shell/org/jnode/shell/help/def/DefaultHelpFactory.java trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java Removed Paths: ------------- trunk/net/src/net/org/jnode/net/help/argument/ trunk/shell/src/shell/org/jnode/shell/help/Argument.java trunk/shell/src/shell/org/jnode/shell/help/Parameter.java trunk/shell/src/shell/org/jnode/shell/help/ParsedArguments.java trunk/shell/src/shell/org/jnode/shell/help/Syntax.java trunk/shell/src/shell/org/jnode/shell/help/argument/ trunk/shell/src/shell/org/jnode/shell/help/def/OldSyntaxHelp.java trunk/shell/src/test/org/jnode/test/shell/MyCatCommand.java trunk/shell/src/test/org/jnode/test/shell/MyDirCommand.java Modified: trunk/shell/descriptors/org.jnode.shell.xml =================================================================== --- trunk/shell/descriptors/org.jnode.shell.xml 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/descriptors/org.jnode.shell.xml 2008-11-22 06:47:09 UTC (rev 4713) @@ -20,7 +20,6 @@ <export name="org.jnode.shell.alias.def.*"/> <export name="org.jnode.shell.def.*"/> <export name="org.jnode.shell.help.*"/> - <export name="org.jnode.shell.help.argument.*"/> <export name="org.jnode.shell.help.def.*"/> <export name="org.jnode.shell.io.*"/> <export name="org.jnode.shell.isolate.*"/> Modified: trunk/shell/src/shell/org/jnode/shell/CommandLine.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/CommandLine.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -25,14 +25,16 @@ import org.jnode.driver.console.CompletionInfo; import org.jnode.shell.help.CompletionException; -import org.jnode.shell.help.Help; -import org.jnode.shell.help.HelpException; -import org.jnode.shell.help.HelpFactory; -import org.jnode.shell.help.Parameter; import org.jnode.shell.io.CommandIO; import org.jnode.shell.io.CommandIOMarker; +import org.jnode.shell.syntax.AliasArgument; +import org.jnode.shell.syntax.Argument; import org.jnode.shell.syntax.ArgumentBundle; +import org.jnode.shell.syntax.ArgumentSyntax; import org.jnode.shell.syntax.CommandSyntaxException; +import org.jnode.shell.syntax.FileArgument; +import org.jnode.shell.syntax.RepeatSyntax; +import org.jnode.shell.syntax.Syntax; import org.jnode.shell.syntax.SyntaxBundle; /** @@ -95,22 +97,6 @@ private static final String[] NO_ARGS = new String[0]; private static final Token[] NO_TOKENS = new Token[0]; - @SuppressWarnings("deprecation") - private final Help.Info defaultInfo = new Help.Info("file", - "default parameter for command line completion", - new Parameter( - new org.jnode.shell.help.argument.FileArgument( - "file", "a file", org.jnode.shell.help.Argument.MULTI), - org.jnode.shell.help.Parameter.OPTIONAL)); - - private final org.jnode.shell.help.Argument defaultArg = - new org.jnode.shell.help.argument.AliasArgument("command", - "the command to be called"); - -// private final Syntax defaultSyntax = new RepeatSyntax(new ArgumentSyntax("argument")); -// private final ArgumentBundle defaultArguments = new ArgumentBundle( -// new FileArgument("argument", org.jnode.shell.syntax.Argument.MULTIPLE)); - private final Token commandToken; private final Token[] argumentTokens; @@ -631,34 +617,33 @@ throw new CompletionException("Problem creating a command instance", ex); } - // Get the command's argument bundle, or the default one. + // Get the command's argument bundle and syntax ArgumentBundle bundle = (command == null) ? null : command.getArgumentBundle(); - - // Get a syntax for the alias, or a default one. SyntaxBundle syntaxes = shell.getSyntaxManager().getSyntaxBundle(cmd); - + + if (bundle == null) { + // We're missing the argument bundle. We assume this is a 'classic' Java application + // that does its own argument parsing and completion like a UNIX shell; i.e. + // completing each argument as a pathname. + Syntax syntax = new RepeatSyntax(new ArgumentSyntax("argument")); + syntaxes = new SyntaxBundle(cmd, syntax); + bundle = new ArgumentBundle( + new FileArgument("argument", Argument.MULTIPLE)); + } else if (syntaxes == null) { + // We're missing the syntax, but we do have an argument bundle. Generate + // a default syntax from the bundle. + syntaxes = new SyntaxBundle(cmd, bundle.createDefaultSyntax()); + } try { - // Try new-style completion if we have a Syntax - if (bundle != null) { - bundle.complete(this, syntaxes, completion); - } else { - // Otherwise, try old-style completion using the command's INFO - try { - Help.Info info = HelpFactory.getInfo(cmdClass.getCommandClass()); - info.complete(completion, this, shell.getOut()); - } catch (HelpException ex) { - // And fall back to old-style completion with an 'info' that - // specifies a sequence of 'file' names. - // FIXME ... - defaultInfo.complete(completion, this, shell.getOut()); - } - } + bundle.complete(this, syntaxes, completion); } catch (CommandSyntaxException ex) { throw new CompletionException("Command syntax problem", ex); } } else { - // do completion on the command name - defaultArg.complete(completion, cmd); + // We haven't got a command name yet, so complete the partial command name string + // as an AliasArgument. + AliasArgument cmdNameArg = new AliasArgument("cmdName", Argument.SINGLE); + cmdNameArg.complete(completion, cmd); completion.setCompletionStart(commandToken == null ? 0 : commandToken.start); } } Modified: trunk/shell/src/shell/org/jnode/shell/CommandRunner.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/CommandRunner.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -144,7 +144,7 @@ } } catch (SyntaxErrorException ex) { try { - HelpFactory.getInfo(cmdInfo.getCommandClass()).usage(shellErr); + HelpFactory.getHelpFactory().getHelp(commandLine.getCommandName(), cmdInfo).usage(shellErr); shellErr.println(ex.getMessage()); } catch (HelpException e) { shellErr.println("Exception while trying to get the command usage"); Modified: trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -117,7 +117,7 @@ } } } catch (SyntaxErrorException ex) { - HelpFactory.getInfo(cmdInfo.getCommandClass()).usage(err); + HelpFactory.getHelpFactory().getHelp(cmdName, cmdInfo).usage(err); err.println(ex.getMessage()); } catch (VmExit ex) { return ex.getStatus(); Deleted: trunk/shell/src/shell/org/jnode/shell/help/Argument.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/Argument.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/help/Argument.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -1,131 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.help; - -import java.io.PrintWriter; - -import org.jnode.driver.console.CompletionInfo; - -/** - * @author qades - */ -public class Argument extends CommandLineElement { - - public static final boolean SINGLE = false; - - public static final boolean MULTI = true; - - private static final String[] NO_VALUES = new String[0]; - - private final boolean multi; - - public Argument(String name, String description, boolean multi) { - super(name, description); - this.multi = multi; - } - - public Argument(String name, String description) { - this(name, description, SINGLE); - } - - public boolean isMulti() { - return multi; - } - - public String format() { - return "<" + getName() + ">" + (isMulti() ? " ..." : ""); - } - - public void describe(HelpFactory help, PrintWriter out) { - help.describeArgument(this, out); - } - - // Command line completion - private String[] values = NO_VALUES; - - private boolean satisfied = false; - - /** - * Perform argument completion on the supplied (partial) argument value. The - * results of the completion should be added to the supplied CompletionInfo. - * <p> - * The default behavior is to return the argument value as a partial completion. - * Subtypes of Argument should override this method if they are capable of doing - * non-trivial completion. Completions should be registered by calling one - * of the 'addCompletion' methods on the CompletionInfo. - * - * @param completion the CompletionInfo object for registering any completions. - * @param partial the argument string to be completed. - */ - public void complete(CompletionInfo completion, String partial) { - completion.addCompletion(partial, true); - } - - protected final void setValue(String value) { - if (isMulti()) { - String[] values = new String[ this.values.length + 1]; - System.arraycopy(this.values, 0, values, 0, this.values.length); - values[ this.values.length] = value; - this.values = values; - } else { - this.values = new String[] {value}; - } - setSatisfied(!isMulti()); - } - - /** - * Override this method to check if a given value "fits" this argument. - * - * @param value - * @return true if value, false otherwise. - */ - protected boolean isValidValue(String value) { - return true; - } - - public final String getValue(ParsedArguments args) { - String[] result = getValues(args); - if ((result == null) || (result.length == 0)) return null; - return result[ 0]; - } - - public final String[] getValues(ParsedArguments args) { - return args.getValues(this); - } - - final String[] getValues() { - return values; - } - - protected final void clear() { - this.values = new String[ 0]; - setSatisfied(false); - } - - protected final void setSatisfied(boolean satisfied) { - this.satisfied = satisfied; - } - - public final boolean isSatisfied() { - return satisfied; - } -} Modified: trunk/shell/src/shell/org/jnode/shell/help/Help.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/Help.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/help/Help.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -22,9 +22,6 @@ import java.io.PrintWriter; -import org.jnode.driver.console.CompletionInfo; -import org.jnode.shell.CommandLine; - /** * This is the interface for an object that outputs command help. Different * implementations support different command syntax mechanisms, and (in the @@ -48,120 +45,4 @@ * @param pw the help information is written here */ public void usage(PrintWriter pw); - - /** - * This class is here for historical reasons. It is a key API class in the - * 'old' JNode syntax mechanism. - */ - public static class Info { - - private final String name; - - private final Syntax[] syntaxes; - - public Info(String name, Syntax... syntaxes) { - this.name = name; - this.syntaxes = syntaxes; - } - - public Info(String name, String description, Parameter... params) { - this(name, new Syntax(description, params)); - } - - /** - * Gets the name of this command - */ - public String getName() { - return name; - } - - /** - * Gets the syntaxes allowed for this command - */ - public Syntax[] getSyntaxes() { - return syntaxes; - } - - public void usage(PrintWriter out) { - try { - HelpFactory.getHelpFactory().usage(this, out); - } catch (HelpException ex) { - ex.printStackTrace(); - } - } - - /** - * Prints the help message. - * @param command command name or alias which appears in the help message - * @throws HelpException - */ - public void help(String command, PrintWriter out) throws HelpException { - HelpFactory.getHelpFactory().help(this, command, out); - } - - public String complete(CompletionInfo completion, CommandLine partial, - PrintWriter out) throws CompletionException { - // The completion strategy is to try to complete each of the - // syntaxes, and return the longest completion string. - String max = ""; - boolean foundCompletion = false; - for (Syntax syntax : syntaxes) { - try { - syntax.complete(completion, partial); - foundCompletion = true; - - } catch (CompletionException ex) { - // just try the next syntax - } - } - if (!foundCompletion) { - out.println(); - usage(out); - throw new CompletionException("Invalid command syntax"); - } - return max; - } - - /** - * Parse the supplied command arguments against this object's syntax(es). - * @param args the command arguments - * @return the resulting binding of parameters/arguments to values. - * @throws SyntaxErrorException - * @deprecated use parse(CommandLine) instead. - * - */ - public ParsedArguments parse(String... args) throws SyntaxErrorException { - return parse(new CommandLine(args)); - } - - /** - * Parse the supplied CommandLine against this object's syntax(es). - * - * @param cmdLine the CommandLine - * @return the resulting binding of parameters/arguments to values. - * @throws SyntaxErrorException - */ - public ParsedArguments parse(CommandLine cmdLine) throws SyntaxErrorException { - for (int i = 0; i < syntaxes.length; i++) { - Syntax s = syntaxes[i]; - // FIXME ... it appears that s.parse is a stateful operation. If that is - // the case, we should either synchronize on s for s.parse + s.clearArguments, - // or move the s.clearArgument call into s.parse. - try { - return s.parse(cmdLine); - } catch (SyntaxErrorException ex) { - s.clearArguments(); - if (syntaxes.length == 1) { - // If there was only one syntax, propagate the exception so that - // we can tell the user why the arguments didn't match. - throw ex; - } - } - } - - // There were no syntaxes, or we have tried more than one syntax and they - // all have failed. - throw new SyntaxErrorException("No matching syntax found"); - } - } } Modified: trunk/shell/src/shell/org/jnode/shell/help/HelpFactory.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/HelpFactory.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/help/HelpFactory.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -22,7 +22,6 @@ package org.jnode.shell.help; import java.io.PrintWriter; -import java.lang.reflect.Field; import java.util.TreeSet; import javax.naming.NamingException; @@ -30,7 +29,6 @@ import org.jnode.naming.InitialNaming; import org.jnode.plugin.PluginUtils; import org.jnode.shell.CommandInfo; -import org.jnode.shell.help.Help.Info; import org.jnode.shell.syntax.ArgumentBundle; import org.jnode.shell.syntax.FlagArgument; import org.jnode.shell.syntax.SyntaxBundle; @@ -63,17 +61,6 @@ return PluginUtils.getLocalizedMessage(HelpFactory.class, BUNDLE_NAME, messageKey); } - - public static Info getInfo(Class<?> clazz) throws HelpException { - try { - Field helpInfo = clazz.getField(INFO_FIELD_NAME); - return (Help.Info) helpInfo.get(null); // static access - } catch (NoSuchFieldException ex) { - throw new HelpException("Command information not found"); - } catch (IllegalAccessException ex) { - throw new HelpException("Command information not accessible"); - } - } /** * Obtain a CommanHelp object for a given command alias and its resolved CommandInfo. @@ -92,15 +79,6 @@ /** * Shows the help page for a command * - * @param info the command info - * @param command a command name or alias which appears in the help - * @param out the destination for help output. - */ - protected abstract void help(Info info, String command, PrintWriter out); - - /** - * Shows the help page for a command - * * @param syntaxes the command's syntax bundle * @param bundle the command's argument bundle * @param out the destination for help output. @@ -110,14 +88,6 @@ /** * Shows the usage line for a command * - * @param info the command information - * @param out the destination for help output. - */ - protected abstract void usage(Info info, PrintWriter out); - - /** - * Shows the usage line for a command - * * @param syntaxes the command's syntax bundle * @param bundle the command's argument bundle * @param out the destination for help output. @@ -128,12 +98,6 @@ * Shows the description of a single argument. Used as a callback in * {@link Argument#describe(HelpFactory)}. */ - protected abstract void describeArgument(Argument arg, PrintWriter out); - - /** - * Shows the description of a single argument. Used as a callback in - * {@link Argument#describe(HelpFactory)}. - */ protected abstract void describeArgument(org.jnode.shell.syntax.Argument<?> arg, PrintWriter out); /** @@ -143,10 +107,4 @@ protected abstract void describeOption(FlagArgument arg, TreeSet<String> flagTokens, PrintWriter out); - /** - * Shows the description of a single parameter. Used as a callback in - * {@link Parameter#describe(HelpFactory)}. - */ - protected abstract void describeParameter(Parameter param, PrintWriter out); - } Deleted: trunk/shell/src/shell/org/jnode/shell/help/Parameter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/Parameter.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/help/Parameter.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -1,146 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.help; - -import java.io.PrintWriter; - -import org.jnode.driver.console.CompletionInfo; - -/** - * @author qades - */ -public class Parameter extends CommandLineElement { - - public static final String ANONYMOUS = ""; - public static final String NO_DESCRIPTION = ""; - public static final Argument NO_ARGUMENT = null; - public static final boolean OPTIONAL = true; - public static final boolean MANDATORY = false; - - private final Argument argument; - private final boolean optional; - - - public Parameter(String name, String description, Argument argument, boolean optional) { - super(name, description); - this.argument = argument; - this.optional = optional; - } - - public Parameter(String name, String description, boolean optional) { - this(name, description, NO_ARGUMENT, optional); - } - - public Parameter(String name, String description, Argument argument) { - this(name, description, argument, OPTIONAL); - } - - public Parameter(Argument argument, boolean optional) { - this(ANONYMOUS, NO_DESCRIPTION, argument, optional); - } - - /** - * A non-optional parameter - * - * @param argument - */ - public Parameter(Argument argument) { - this(ANONYMOUS, NO_DESCRIPTION, argument, MANDATORY); - } - - public final boolean isAnonymous() { - return ANONYMOUS.equals(getName()); - } - - public final String getDescription() { - if (isAnonymous()) { - return NO_DESCRIPTION; - } - return super.getDescription(); - } - - public final boolean hasArgument() { - return argument != NO_ARGUMENT; - } - - public final Argument getArgument() { - return argument; - } - - public final boolean isOptional() { - return optional; - } - - public String format() { - String result = ""; - if (!isAnonymous()) { - result += "-" + getName(); - // be aware of trailing space - if (hasArgument() && (argument.format().length() != 0)) { - result += " "; - } - } - if (hasArgument()) { - result += argument.format(); - } - return (optional ? "[" + result + "]" : result); - } - - public void describe(HelpFactory help, PrintWriter out) { - if (!isAnonymous()) { - help.describeParameter(this, out); - } - if (hasArgument()) { - argument.describe(help, out); - } - } - - public final void complete(CompletionInfo completion, String partial) { - // delegate to argument, merely close the parameter if no argument - // exists - if (hasArgument()) { - if (Syntax.DEBUG) { - Syntax.LOGGER.debug("Parameter.complete: argument is " + argument.format()); - } - argument.complete(completion, partial); - } else { - // FIXME - this assumes that the partial string can never - // legitimately - // have leading/trailing whitespace. - if (Syntax.DEBUG) - Syntax.LOGGER.debug("Parameter.complete: no argument"); - completion.addCompletion(" "); - } - } - - public final boolean isSatisfied() { - if (!hasArgument()) { - return true; - } - return argument.isSatisfied(); - } - - public final boolean isSet(ParsedArguments args) { - return args.isSet(this); - } - -} Deleted: trunk/shell/src/shell/org/jnode/shell/help/ParsedArguments.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/ParsedArguments.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/help/ParsedArguments.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -1,77 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.help; - -import java.util.Map; - -/** - * @author qades - */ -public class ParsedArguments { - - private final Map<CommandLineElement, String[]> args; - - ParsedArguments(Map<CommandLineElement, String[]> args) { - this.args = args; - } - - public final int size() { - return args.size(); - } - - final String[] getValues(Argument arg) { - return (String[]) args.get(arg); - } - - final boolean isSet(Parameter param) { - return args.containsKey(param); - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("{"); - for (Map.Entry<CommandLineElement, String[]> entry : args.entrySet()) { - if (sb.charAt(sb.length() - 1) != '{') { - sb.append(','); - } - sb.append(entry.getKey().format()).append("->"); - if (entry.getValue() == null) { - sb.append("null"); - } else { - sb.append('['); - for (String value : entry.getValue()) { - if (sb.charAt(sb.length() - 1) != '[') { - sb.append(','); - } - if (value == null) { - sb.append("null"); - } else { - sb.append('"').append(value).append('"'); - } - } - sb.append(']'); - } - } - sb.append("}"); - return sb.toString(); - } -} Deleted: trunk/shell/src/shell/org/jnode/shell/help/Syntax.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/Syntax.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/help/Syntax.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -1,367 +0,0 @@ -/* - * $Id$ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.shell.help; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; - -import org.apache.log4j.Logger; -import org.jnode.driver.console.CompletionInfo; -import org.jnode.shell.CommandLine; -import org.jnode.shell.help.argument.OptionArgument; - -/** - * @author qades - * @author cr...@jn... - */ -@SuppressWarnings("deprecation") -public class Syntax { - - public static final boolean DEBUG = false; - public static final Logger LOGGER = Logger.getLogger(Syntax.class); - - private final String description; - - private final Parameter[] params; - - public Syntax(String description, Parameter... params) { - this.description = description; - this.params = params; - } - - /** - * Gets the description of this syntax - */ - public String getDescription() { - return description; - } - - /** - * Gets the parameters of this syntax - */ - public Parameter[] getParams() { - return params; - } - - public void complete(CompletionInfo completion, CommandLine partial) throws CompletionException { - Parameter param; - CommandLine.Token value; - int tokenType; - - if (DEBUG) LOGGER.debug("Syntax.complete: this.description = " + this.description); - - CompletionVisitor visitor = new CompletionVisitor(); - try { - param = visitCommandLine(partial, visitor); - } catch (SyntaxErrorException ex) { - throw new CompletionException(ex.getMessage()); - } - - if (DEBUG) LOGGER.debug("Syntax.complete: initial param = " + - ((param == null) ? "null" : param.format()) + ", argumentAnticipated = " + - partial.isArgumentAnticipated()); - - if (param != null && partial.isArgumentAnticipated()) { - value = null; - tokenType = CommandLine.LITERAL; - } else { - param = visitor.getLastParam(); - value = visitor.getLastValue(); - tokenType = visitor.getLastTokenType(); - } - - if (param == null) { - if (DEBUG) LOGGER.debug("Syntax.complete: no param"); - // completion.addCompletion(" "); - return; - } - if (DEBUG) LOGGER.debug("Syntax.complete: param = " + param.format() + ", value = " + value + - ", tokenType = " + tokenType); - - if (param.hasArgument()) { - if (value != null) { - param.complete(completion, value.token); - completion.setCompletionStart(value.start); - } else { - param.complete(completion, ""); - } - } else if (!param.isAnonymous()) { - completion.addCompletion("-" + param.getName()); - } - } - - synchronized ParsedArguments parse(CommandLine cmdLine) throws SyntaxErrorException { - if (DEBUG) LOGGER.debug("Syntax.parse: this.description = " + this.description); - - if (params.length == 0) { - if (cmdLine.getLength() == 0) { - if (DEBUG) LOGGER.debug("Syntax.parse: returning no args"); - return new ParsedArguments(new HashMap<CommandLineElement, String[]>()); - } - if (DEBUG) LOGGER.debug("Syntax.parse: takes no parameter"); - throw new SyntaxErrorException("Syntax takes no parameter"); - } - - final ParseVisitor visitor = new ParseVisitor(); - visitCommandLine(cmdLine, visitor); - final ParsedArguments result = new ParsedArguments(visitor.getArgumentMap()); - - // check if all mandatory parameters are set - for (Parameter p : params) { - if (!p.isOptional() && !p.isSet(result)) { - if (DEBUG) LOGGER.debug("Syntax.parse: parameter " + p.format() + " not set"); - throw new SyntaxErrorException("Mandatory parameter " + p.format() + " not set"); - } - } - if (DEBUG) LOGGER.debug("Syntax.parse: returning '" + result.toString() + "'"); - return result; - } - - private synchronized Parameter visitCommandLine( - CommandLine cmdLine, CommandLineVisitor visitor) - throws SyntaxErrorException { - clearArguments(); - Parameter param = null; - final ParameterIterator paramIterator = new ParameterIterator(); - - // FIXME - should use a Token iterator here ... - final Iterator<CommandLine.Token> it = cmdLine.tokenIterator(); - boolean acceptNames = true; - CommandLine.Token token = it.hasNext() ? it.next() : null; - while (token != null) { - if (DEBUG) LOGGER.debug("Syntax.visitor: arg '" + token + "'"); - if (param == null) { - // Trying to match a Parameter. - if (acceptNames && "--".equals(token)) { - acceptNames = false; - token = it.hasNext() ? it.next() : null; - } else if (paramIterator.hasNext()) { - param = (Parameter) paramIterator.next(); - // FIXME real hacky stuff here!! I'm trying to stop anonymous parameters matching - // "-name" ... except when they should ... - if (param.isAnonymous()) { - if (token.token.charAt(0) != '-' || param.getArgument() instanceof OptionArgument) { - if (DEBUG) LOGGER.debug("Syntax.visitor: trying anonymous param " + param.format()); - visitor.visitParameter(param); - } else { - param = null; - } - } else if (acceptNames && token.equals("-" + param.getName())) { - if (DEBUG) LOGGER.debug("Syntax.visitor: trying named param " + param.format()); - visitor.visitParameter(param); - token = it.hasNext() ? it.next() : null; - } else { - if (DEBUG) LOGGER.debug("Syntax.visitor: skipping named param " + param.format()); - param = null; - } - } else { - if (DEBUG) LOGGER.debug("Syntax.visitor: no param for '" + token + "'"); - throw new SyntaxErrorException("Unexpected argument '" + token + "'"); - } - } - if (param != null) { - // Have a Parameter. Trying to match its Argument. - final boolean last = !it.hasNext() && !cmdLine.isArgumentAnticipated(); - Argument arg = param.getArgument(); - if (arg == null) { - visitor.visitValue(null, last, CommandLine.LITERAL); - } else if (token != null) { - CommandLine.Token value = visitor.visitValue(token, last, CommandLine.LITERAL); - if (visitor.isValueValid(arg, value, last)) { - arg.setValue(value.token); - token = it.hasNext() ? it.next() : null; - } else if (!param.isOptional()) { - if (DEBUG) LOGGER.debug("Syntax.visitor: bad value '" + token + - "' for mandatory param " + param.format()); - throw new SyntaxErrorException("Invalid value for argument"); - } else { - if (DEBUG) LOGGER.debug("Syntax.visitor: bad value '" + token + - "' optional param " + param.format()); - if (DEBUG) LOGGER.debug("Syntax.visitor: clearing param"); - param = null; - } - } else if (!param.isOptional()) { - if (DEBUG) LOGGER.debug("Syntax.visitor: missing arg for mandatory param " + param.format()); - // FIXME .. what if param is anonymous? - throw new SyntaxErrorException("Missing argument value for '" + - param.getName() + "' option"); - } - - if (param != null && param.isSatisfied()) { - if (DEBUG) LOGGER.debug("Syntax.visitor: param " + param.format() + " is satisfied"); - if (!last || cmdLine.isArgumentAnticipated()) { - if (DEBUG) LOGGER.debug("Syntax.visitor: clearing param"); - param = null; - } - } - } - } - while (param == null && paramIterator.hasNext()) { - param = (Parameter) paramIterator.next(); - if (param.isAnonymous()) { - if (DEBUG) LOGGER.debug("Syntax.visitor: setting param " + param.format() + " at end"); - break; - } - param = null; - } - return param; - } - - final void clearArguments() { - for (Parameter param : params) - if (param.hasArgument()) param.getArgument().clear(); - } - - /** - * Visitor for command line elements. - * - * @author Ewout Prangsma (ep...@us...) - */ - private interface CommandLineVisitor { - - public void visitParameter(Parameter p); - - public CommandLine.Token visitValue(CommandLine.Token token, boolean last, int tokenType); - - public boolean isValueValid(Argument arg, CommandLine.Token value, boolean last); - } - - private class CompletionVisitor implements CommandLineVisitor { - private Parameter param = null; - private CommandLine.Token value; - private int tokenType; - private boolean last; - - public CompletionVisitor() { - } - - public void visitParameter(Parameter p) { - if (DEBUG) LOGGER.debug("CompletionVisitor: param = " + p.format()); - this.param = p; - this.last = true; - this.value = null; - this.tokenType = 0; - } - - public CommandLine.Token visitValue( - CommandLine.Token token, boolean last, int tokenType) { - if (DEBUG) LOGGER.debug("CompletionVisitor: value = '" + token.token + "', " + last + ", " + tokenType); - this.last = last; - if (last) { - this.value = token; - this.tokenType = tokenType; - } - return token; - } - - public boolean isValueValid(Argument arg, CommandLine.Token value, boolean last) { - if (DEBUG) LOGGER.debug("CompletionVisitor: isValueValid " + arg.format() + - ", " + last + ", " + tokenType); - boolean res = last || arg.isValidValue(value.token); - if (DEBUG) LOGGER.debug("CompletionVisitor: isValueValid -> " + res); - return res; - } - - public Parameter getLastParam() { - return last ? this.param : null; - } - - public CommandLine.Token getLastValue() { - return last ? this.value : null; - } - - public int getLastTokenType() { - return last ? this.tokenType : -1; - } - } - - private class ParseVisitor implements CommandLineVisitor { - - Map<CommandLineElement, String[]> result = new HashMap<CommandLineElement, String[]>(); - - Parameter param = null; - - boolean valued = false; - - public void visitParameter(Parameter p) { - finishParameter(); - this.param = p; - } - - public CommandLine.Token visitValue(CommandLine.Token s, boolean last, int tokenType) { - if (last && s == null) return null; - valued = true; - return s; - } - - final Map<CommandLineElement, String[]> getArgumentMap() { - finishParameter(); - return result; - } - - void finishParameter() { - if (param == null) return; - - if (valued || !param.hasArgument()) { - result.put(param, null); // mark it as "set" - } - if (param.hasArgument()) { - Argument arg = param.getArgument(); - result.put(arg, arg.getValues()); - } - param = null; - valued = false; - } - - public boolean isValueValid(Argument arg, CommandLine.Token value, boolean last) { - return arg.isValidValue(value.token); - } - } - - class ParameterIterator implements Iterator<Parameter> { - final Parameter[] params = Syntax.this.params; - final int length = params.length; - - private int nextParamsIdx = 0; - - public ParameterIterator() { - } - - public boolean hasNext() { - return (nextParamsIdx < length); - } - - public Parameter next() { - if (nextParamsIdx < length) { - return params[nextParamsIdx++]; - } else { - throw new NoSuchElementException(); - } - } - - public void remove() { - throw new UnsupportedOperationException(); - } - } -} Modified: trunk/shell/src/shell/org/jnode/shell/help/def/DefaultHelpFactory.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/def/DefaultHelpFactory.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/help/def/DefaultHelpFactory.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -29,12 +29,9 @@ import org.jnode.shell.CommandInfo; import org.jnode.shell.Shell; import org.jnode.shell.ShellUtils; -import org.jnode.shell.help.Argument; import org.jnode.shell.help.Help; import org.jnode.shell.help.HelpException; import org.jnode.shell.help.HelpFactory; -import org.jnode.shell.help.Parameter; -import org.jnode.shell.help.Syntax; import org.jnode.shell.syntax.ArgumentBundle; import org.jnode.shell.syntax.FlagArgument; import org.jnode.shell.syntax.OptionSyntax; @@ -61,13 +58,11 @@ @Override public Help getHelp(String alias, CommandInfo cmdInfo) throws HelpException { - Help.Info info = null; SyntaxBundle syntaxes = null; ArgumentBundle bundle = null; try { final Shell shell = ShellUtils.getShellManager().getCurrentShell(); final SyntaxManager syntaxManager = shell.getSyntaxManager(); - Class<?> clazz = cmdInfo.getCommandClass(); Command cmd = cmdInfo.createCommandInstance(); if (cmd != null) { bundle = cmd.getArgumentBundle(); @@ -75,40 +70,18 @@ if (syntaxes == null) { syntaxes = new SyntaxBundle(alias, bundle.createDefaultSyntax()); } - } else { - info = HelpFactory.getInfo(clazz); - } - } catch (HelpException ex) { - throw ex; + } } catch (Exception ex) { throw new HelpException(ex.getMessage(), ex); } - if (info != null && alias != null) { - return new OldSyntaxHelp(info, alias); - } else if (syntaxes != null && bundle != null) { + if (syntaxes != null && bundle != null) { return new NewSyntaxHelp(syntaxes, bundle); } else { return null; } } - /** - * Shows the complete help for a command. - * - * @see HelpFactory#help(org.jnode.shell.help.HelpFactory.Info, String) - */ - public void help(Help.Info info, String command, PrintWriter out) { - final Syntax[] syntaxes = info.getSyntaxes(); - final String name = command == null ? info.getName() : command; - for (int i = 0; i < syntaxes.length; i++) { - help(name, syntaxes[i], out); - if (i < syntaxes.length) { - out.println(); - } - } - } - @Override public void help(SyntaxBundle syntaxes, ArgumentBundle bundle, PrintWriter out) { usage(syntaxes, bundle, out); @@ -173,47 +146,6 @@ } } - /** - * Shows the help for a command syntax. - */ - public void help(String name, Syntax syntax, PrintWriter out) { - usage(name, syntax, out); - if (syntax.getDescription() != null) { - out.println("\n" + HelpFactory.getLocalizedHelp("help.description") + ":"); - format(out, new Cell[]{new Cell(4, NOMINAL_WIDTH - 4)}, - new String[]{syntax.getDescription()}); - } - final Parameter[] params = syntax.getParams(); - if (params.length != 0) { - out.println("\n" + HelpFactory.getLocalizedHelp("help.parameters") + ":"); - for (int i = 0; i < params.length; i++) { - params[i].describe(this, out); - } - } - } - - /** - * Shows the usage information of a command. - */ - public void usage(Help.Info info, PrintWriter out) { - final Syntax[] syntaxes = info.getSyntaxes(); - for (int i = 0; i < syntaxes.length; i++) { - usage(info.getName(), syntaxes[i], out); - } - } - - /** - * Shows the usage information of a command. - */ - public void usage(String name, Syntax syntax, PrintWriter out) { - StringBuilder line = new StringBuilder(name); - final Parameter[] params = syntax.getParams(); - for (int i = 0; i < params.length; i++) { - line.append(' ').append(params[i].format()); - } - out.println(HelpFactory.getLocalizedHelp("help.usage") + ": " + line); - } - @Override public void usage(SyntaxBundle syntaxBundle, ArgumentBundle bundle, PrintWriter out) { String command = syntaxBundle.getAlias(); @@ -241,17 +173,7 @@ format(out, cells, texts); } } - - public void describeParameter(Parameter param, PrintWriter out) { - format(out, new Cell[]{new Cell(2, 18), new Cell(2, NOMINAL_WIDTH - 22)}, - new String[]{param.getName(), param.getDescription()}); - } - - public void describeArgument(Argument arg, PrintWriter out) { - format(out, new Cell[]{new Cell(4, 16), new Cell(2, NOMINAL_WIDTH - 22)}, - new String[]{arg.getName(), arg.getDescription()}); - } - + @Override public void describeArgument(org.jnode.shell.syntax.Argument<?> arg, PrintWriter out) { String description = "(" + arg.getTypeDescription() + ") " + arg.getDescription(); Deleted: trunk/shell/src/shell/org/jnode/shell/help/def/OldSyntaxHelp.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/help/def/OldSyntaxHelp.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/shell/org/jnode/shell/help/def/OldSyntaxHelp.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -1,88 +0,0 @@ -package org.jnode.shell.help.def; - -import java.io.PrintWriter; - -import org.jnode.shell.help.Argument; -import org.jnode.shell.help.Help; -import org.jnode.shell.help.HelpFactory; -import org.jnode.shell.help.Parameter; -import org.jnode.shell.help.Syntax; - -/** - * This Help implementation provides for 'old' syntax commands in plain text format. - * - * @author cr...@jn... - */ -public class OldSyntaxHelp extends TextHelpBase implements Help { - private final Info info; - private final String command; - - public OldSyntaxHelp(Info info, String command) { - this.info = info; - this.command = command; - } - - @Override - public void help(PrintWriter pw) { - final Syntax[] syntaxes = info.getSyntaxes(); - for (int i = 0; i < syntaxes.length; i++) { - help(syntaxes[i], pw); - if (i < syntaxes.length) { - pw.println(); - } - } - } - - @Override - public void usage(PrintWriter pw) { - final Syntax[] syntaxes = info.getSyntaxes(); - for (int i = 0; i < syntaxes.length; i++) { - usage(syntaxes[i], pw); - if (i < syntaxes.length) { - pw.println(); - } - } - } - - private String commandName() { - return command == null ? info.getName() : command; - } - - /** - * Shows the help for a command syntax. - */ - public void help(Syntax syntax, PrintWriter pw) { - usage(syntax, pw); - if (syntax.getDescription() != null) { - pw.println("\n" + HelpFactory.getLocalizedHelp("help.description") + ":"); - format(pw, new TextCell[]{new TextCell(4, NOMINAL_WIDTH - 4)}, - new String[]{syntax.getDescription()}); - } - final Parameter[] params = syntax.getParams(); - if (params.length != 0) { - pw.println("\n" + HelpFactory.getLocalizedHelp("help.parameters") + ":"); - for (int i = 0; i < params.length; i++) { - describeParameter(params[i], pw); - } - } - } - - private void usage(Syntax syntax, PrintWriter pw) { - StringBuilder line = new StringBuilder(commandName()); - final Parameter[] params = syntax.getParams(); - for (int i = 0; i < params.length; i++) { - line.append(' ').append(params[i].format()); - } - pw.println(HelpFactory.getLocalizedHelp("help.usage") + ": " + line); - } - - public void describeParameter(Parameter param, PrintWriter out) { - format(out, new TextCell[]{new TextCell(2, 18), new TextCell(2, NOMINAL_WIDTH - 22)}, - new String[]{param.getName(), param.getDescription()}); - } - - public void describeArgument(Argument arg, PrintWriter out) { - format(out, new TextCell[]{new TextCell(4, 16), new TextCell(2, NOMINAL_WIDTH - 22)}, - new String[]{arg.getName(), arg.getDescription()}); - } -} Modified: trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/test/org/jnode/test/shell/CompletionTest.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -131,59 +131,6 @@ } } - public void testDefaultInterpreterOldSyntax() throws Exception { - TestCommandShell cs = new TestCommandShell(); - cs.setCommandInterpreter("default"); - - checkCompletions(cs, "", aliasCompletions, -1); - checkCompletions(cs, "di", new String[]{"dir "}, 0); - checkCompletions(cs, "dir", new String[]{"dir "}, 0); - checkCompletions(cs, "dir ", new String[]{"Four/", "One ", "Three ", "Two "}, -1); - checkCompletions(cs, "dir T", new String[]{"Three ", "Two "}, 4); - - // The default interpreter doesn't recognize '>' '<' or '|' as anything special. - // Therefore it should just try to complete them as filenames ... and fail. - checkCompletions(cs, "dir |", new String[]{}, -1); - checkCompletions(cs, "dir | ", new String[]{}, -1); // dir takes one argument only - checkCompletions(cs, "cat | ", new String[]{"Four/", "One ", "Three ", "Two "}, -1); - checkCompletions(cs, "cat | ca", new String[]{}, -1); - checkCompletions(cs, "cat >", new String[]{}, -1); - checkCompletions(cs, "cat > ", new String[]{"Four/", "One ", "Three ", "Two "}, -1); - checkCompletions(cs, "cat <", new String[]{}, -1); - checkCompletions(cs, "cat < ", new String[]{"Four/", "One ", "Three ", "Two "}, -1); - } - - public void testOldSyntaxOptions() throws Exception { - TestCommandShell cs = new TestCommandShell(); - cs.setCommandInterpreter("default"); - - // For bug #4418 - checkCompletions(cs, "cat -", new String[]{"-u "}, -2); - checkCompletions(cs, "cat -u", new String[]{"-u "}, -2); - - // And some more ... - } - - public void testRedirectingInterpreterOldSyntax() throws Exception { - TestCommandShell cs = new TestCommandShell(); - cs.setCommandInterpreter("redirecting"); - - checkCompletions(cs, "", aliasCompletions, -1); - checkCompletions(cs, "di", new String[]{"dir "}, 0); - checkCompletions(cs, "dir", new String[]{"dir "}, 0); - checkCompletions(cs, "dir ", new String[]{"Four/", "One ", "Three ", "Two "}, -1); - checkCompletions(cs, "dir T", new String[]{"Three ", "Two "}, 4); - checkCompletions(cs, "dir |", aliasCompletions, -1); - checkCompletions(cs, "dir | ", aliasCompletions, -1); - checkCompletions(cs, "cat |", aliasCompletions, -1); - checkCompletions(cs, "cat | ", aliasCompletions, -1); - checkCompletions(cs, "cat | ca", new String[]{"cat "}, 6); - checkCompletions(cs, "cat >", new String[]{"Four/", "One ", "Three ", "Two "}, -1); - checkCompletions(cs, "cat > ", new String[]{"Four/", "One ", "Three ", "Two "}, -1); - checkCompletions(cs, "cat <", new String[]{"Four/", "One ", "Three ", "Two "}, -1); - checkCompletions(cs, "cat < ", new String[]{"Four/", "One ", "Three ", "Two "}, -1); - } - public void testDefaultInterpreterNewSyntax() throws Exception { TestCommandShell cs = new TestCommandShell(); cs.setCommandInterpreter("default"); Deleted: trunk/shell/src/test/org/jnode/test/shell/MyCatCommand.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/MyCatCommand.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/test/org/jnode/test/shell/MyCatCommand.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -1,63 +0,0 @@ -/* - * $Id: CatCommand.java 3603 2007-11-25 21:43:50Z lsantha $ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.test.shell; - -import org.jnode.shell.AbstractCommand; -import org.jnode.shell.help.Help; -import org.jnode.shell.help.Parameter; -import org.jnode.shell.help.Syntax; -import org.jnode.shell.help.argument.FileArgument; -import org.jnode.shell.help.argument.URLArgument; - -/** - * Cut down test class - */ -@SuppressWarnings("deprecation") -public class MyCatCommand extends AbstractCommand { - - static final FileArgument ARG_FILE = new FileArgument("file", - "the files to be concatenated", true); - - static final URLArgument ARG_URL = new URLArgument("url", - "the files to be concatenated", true); - - public static Help.Info HELP_INFO = new Help.Info("cat", - new Syntax[]{ - new Syntax( - "Fetch the argument urls and copy their contents to standard output.", - new Parameter[]{ - new Parameter("u", - "selects urls rather than pathnames", - ARG_URL, Parameter.MANDATORY)}), - new Syntax( - "Read the argument files, copying their contents to standard output. " + - "If there are no arguments, standard input is read until EOF is reached; " + - "e.g. ^D when reading keyboard input.", - new Parameter[]{ - new Parameter(ARG_FILE, Parameter.OPTIONAL)}) - - }); - - public void execute() throws Exception { - } - -} Deleted: trunk/shell/src/test/org/jnode/test/shell/MyDirCommand.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/MyDirCommand.java 2008-11-22 03:25:44 UTC (rev 4712) +++ trunk/shell/src/test/org/jnode/test/shell/MyDirCommand.java 2008-11-22 06:47:09 UTC (rev 4713) @@ -1,44 +0,0 @@ -/* - * $Id: DirCommand.java 3590 2007-11-17 19:28:05Z lsantha $ - * - * JNode.org - * Copyright (C) 2003-2006 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.test.shell; - -import org.jnode.shell.AbstractCommand; -import org.jnode.shell.help.Help; -import org.jnode.shell.help.Parameter; -import org.jnode.shell.help.argument.FileArgument; - -/** - * Cut down test class ... dir done the old way - */ -@SuppressWarnings("deprecation") -public class MyDirCommand extends AbstractCommand { - static final FileArgument ARG_PATH = new FileArgument("path", "the path to list contents of"); - public static Help.Info HELP_INFO = - new Help.Info( - "dir", - "List the entries of the given path", - new Parameter[]{new Parameter(ARG_PATH, Parameter.OPTIONAL)}); - - public void execute() throws Exception { - // suddenly ... nothing happened - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |