Changeset 731


Ignore:
Timestamp:
08/31/12 12:03:53 (12 years ago)
Author:
sherbold
Message:
  • listCommands now lists the commands ordered by the package
Location:
trunk/java-utils/src/main/java/de/ugoe/cs/util/console
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-utils/src/main/java/de/ugoe/cs/util/console/CommandExecuter.java

    r718 r731  
    297297        return commandArray; 
    298298    } 
     299     
     300    /** 
     301     * <p> 
     302     * Get a copy of the currently registered command packages. 
     303     * </p> 
     304     * 
     305     * @return currently registered command packages 
     306     */ 
     307    public List<String> getCommandPackages() { 
     308        List<String> commandPackageListCopy = new ArrayList<String>(commandPackageList); 
     309        commandPackageListCopy.add(0, defaultPackage); 
     310        return commandPackageListCopy; 
     311    } 
    299312} 
  • trunk/java-utils/src/main/java/de/ugoe/cs/util/console/defaultcommands/CMDlistCommands.java

    r664 r731  
    2727        Command[] commands = CommandExecuter.getInstance().getAvailableCommands(); 
    2828 
    29         for (Command command : commands) { 
    30             Console.println(command.help()); 
     29        List<String> commandPackages = CommandExecuter.getInstance().getCommandPackages(); 
     30         
     31        for( String commandPackage : commandPackages ) { 
     32            Console.println(commandPackage); 
     33            for (Command command : commands) { 
     34                if( commandPackage.equals(command.getClass().getPackage().getName())) { 
     35                    Console.println("   " + command.help()); 
     36                } 
     37            } 
    3138        } 
    3239    } 
Note: See TracChangeset for help on using the changeset viewer.