source: trunk/java-utils/src/main/java/de/ugoe/cs/util/console/defaultcommands/CMDlistCommands.java @ 731

Last change on this file since 731 was 731, checked in by sherbold, 12 years ago
  • listCommands now lists the commands ordered by the package
File size: 1.3 KB
Line 
1
2package de.ugoe.cs.util.console.defaultcommands;
3
4import java.util.List;
5
6import de.ugoe.cs.util.console.Command;
7import de.ugoe.cs.util.console.CommandExecuter;
8import de.ugoe.cs.util.console.Console;
9
10/**
11 * <p>
12 * Command to list all events (symbols) known to a usage profile (stochastic process).
13 * </p>
14 *
15 * @author Steffen Herbold
16 * @version 1.0
17 */
18public class CMDlistCommands implements Command {
19
20    /*
21     * (non-Javadoc)
22     *
23     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
24     */
25    @Override
26    public void run(List<Object> parameters) {
27        Command[] commands = CommandExecuter.getInstance().getAvailableCommands();
28
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            }
38        }
39    }
40
41    /*
42     * (non-Javadoc)
43     *
44     * @see de.ugoe.cs.util.console.Command#help()
45     */
46    @Override
47    public String help() {
48        return "listCommands";
49    }
50
51}
Note: See TracBrowser for help on using the repository browser.