1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
2 | //
|
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
4 | // you may not use this file except in compliance with the License.
|
---|
5 | // You may obtain a copy of the License at
|
---|
6 | //
|
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
8 | //
|
---|
9 | // Unless required by applicable law or agreed to in writing, software
|
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
12 | // See the License for the specific language governing permissions and
|
---|
13 | // limitations under the License.
|
---|
14 |
|
---|
15 | package de.ugoe.cs.util.console.defaultcommands;
|
---|
16 |
|
---|
17 | import java.util.List;
|
---|
18 |
|
---|
19 | import de.ugoe.cs.util.console.Command;
|
---|
20 | import de.ugoe.cs.util.console.CommandExecuter;
|
---|
21 | import de.ugoe.cs.util.console.Console;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * <p>
|
---|
25 | * Command to list all events (symbols) known to a usage profile (stochastic process).
|
---|
26 | * </p>
|
---|
27 | *
|
---|
28 | * @author Steffen Herbold
|
---|
29 | * @version 1.0
|
---|
30 | */
|
---|
31 | public class CMDlistCommands implements Command {
|
---|
32 |
|
---|
33 | /*
|
---|
34 | * (non-Javadoc)
|
---|
35 | *
|
---|
36 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
37 | */
|
---|
38 | @Override
|
---|
39 | public void run(List<Object> parameters) {
|
---|
40 | Command[] commands = CommandExecuter.getInstance().getAvailableCommands();
|
---|
41 |
|
---|
42 | List<String> commandPackages = CommandExecuter.getInstance().getCommandPackages();
|
---|
43 |
|
---|
44 | for (String commandPackage : commandPackages) {
|
---|
45 | String[] packageSplit = commandPackage.split("\\.");
|
---|
46 | if (packageSplit[packageSplit.length - 1].equals("commands")) {
|
---|
47 | Console.println(packageSplit[packageSplit.length - 2]);
|
---|
48 | }
|
---|
49 | else if (packageSplit[packageSplit.length - 1].equals("defaultcommands")) {
|
---|
50 | Console.println("general");
|
---|
51 | }
|
---|
52 | else {
|
---|
53 | Console.println(packageSplit[packageSplit.length - 1]);
|
---|
54 | }
|
---|
55 | for (Command command : commands) {
|
---|
56 | if (commandPackage.equals(command.getClass().getPackage().getName())) {
|
---|
57 | Console.println(" " + command.help());
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * (non-Javadoc)
|
---|
65 | *
|
---|
66 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
67 | */
|
---|
68 | @Override
|
---|
69 | public String help() {
|
---|
70 | return "listCommands";
|
---|
71 | }
|
---|
72 |
|
---|
73 | }
|
---|