Changeset 664 for trunk/java-utils/src/main/java/de/ugoe/cs
- Timestamp:
- 08/28/12 13:33:23 (12 years ago)
- Location:
- trunk/java-utils/src/main/java/de/ugoe/cs/util/console
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/Command.java
r175 r664 27 27 /** 28 28 * <p> 29 * Sends information about how to use a command to the console.29 * Returns a string the contains information about how to use the command. 30 30 * </p> 31 * @return help string 31 32 */ 32 public voidhelp();33 public String help(); 33 34 } -
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/CommandExecuter.java
r661 r664 10 10 import java.util.ArrayList; 11 11 import java.util.Arrays; 12 import java.util.Collections; 13 import java.util.Comparator; 12 14 import java.util.Enumeration; 13 15 import java.util.List; … … 138 140 } 139 141 catch (InvalidParameterException e) { 140 cmd.help();142 Console.println("Usage: " + cmd.help()); 141 143 } 142 144 } … … 181 183 * @return an array containing the names of the available commands. 182 184 */ 183 public String[] getAvailableCommands() {184 List< String> commands = new ArrayList<String>();185 public Command[] getAvailableCommands() { 186 List<Command> commands = new ArrayList<Command>(); 185 187 List<String> packages = new ArrayList<String>(); 186 188 packages.addAll(commandPackageList); … … 251 253 } 252 254 255 Collections.sort(classNames, new Comparator<String>() { 256 @Override 257 public int compare(String arg1, String arg2) { 258 String str1 = arg1.substring(arg1.lastIndexOf('.') + cmdPrefix.length() + 1); 259 String str2 = arg2.substring(arg2.lastIndexOf('.') + cmdPrefix.length() + 1); 260 return str1.compareTo(str2); 261 } 262 263 }); 253 264 for (String className : classNames) { 254 265 String commandStr = … … 261 272 // class may still be inner classes. Therefore load the command, to 262 273 // see if it is really available and a command. 263 if (loadCMD(className) != null) { 264 commands.add(commandStr); 274 Command cmd = loadCMD(className); 275 if (cmd != null) { 276 commands.add(cmd); 265 277 } 266 278 } 267 279 } 268 280 269 String[] commandArray = commands.toArray(new String[commands.size()]); 270 Arrays.sort(commandArray); 281 Command[] commandArray = commands.toArray(new Command[commands.size()]); 271 282 return commandArray; 272 283 } -
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/defaultcommands/CMDexec.java
r639 r664 63 63 */ 64 64 @Override 65 public voidhelp() {66 Console.println("Usage: exec <filename>");65 public String help() { 66 return "exec <filename>"; 67 67 } 68 68 } -
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/defaultcommands/CMDexit.java
r175 r664 4 4 5 5 import de.ugoe.cs.util.console.Command; 6 import de.ugoe.cs.util.console.Console;7 6 8 7 /** … … 22 21 */ 23 22 @Override 24 public voidhelp() {25 Console.println("Usage: exit");23 public String help() { 24 return "exit"; 26 25 } 27 26 -
trunk/java-utils/src/main/java/de/ugoe/cs/util/console/defaultcommands/CMDlistCommands.java
r663 r664 1 1 2 package de.ugoe.cs. quest.ui.commands;2 package de.ugoe.cs.util.console.defaultcommands; 3 3 4 4 import java.util.List; … … 25 25 @Override 26 26 public void run(List<Object> parameters) { 27 String[] commands = CommandExecuter.getInstance().getAvailableCommands();27 Command[] commands = CommandExecuter.getInstance().getAvailableCommands(); 28 28 29 for ( Stringcommand : commands) {30 Console.println(command );29 for (Command command : commands) { 30 Console.println(command.help()); 31 31 } 32 32 } … … 38 38 */ 39 39 @Override 40 public voidhelp() {41 Console.println("Usage: listCommands");40 public String help() { 41 return "listCommands"; 42 42 } 43 43
Note: See TracChangeset
for help on using the changeset viewer.