-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathCommandProvider.java
More file actions
37 lines (28 loc) · 881 Bytes
/
CommandProvider.java
File metadata and controls
37 lines (28 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.utplsql.cli;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
public class CommandProvider {
private Map<String, ICommand> commands;
public CommandProvider() {
init();
}
private void init() {
commands = new HashMap<>();
addCommand(new RunCommand());
addCommand(new VersionInfoCommand());
addCommand(new ReportersCommand());
}
private void addCommand( ICommand command ) {
commands.put(command.getCommand().toLowerCase(), command);
}
public ICommand getCommand( String key ) {
if ( commands.containsKey(key))
return commands.get(key.toLowerCase());
else
return new HelpCommand("Unknown command: '" + key + "'");
}
public Stream<ICommand> commands() {
return commands.values().stream();
}
}