Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@
* Class is an interface for commands.
*/
public interface Command {

/**
* Get command description.
* @return Description
*/
String description();
String getDescription();

/**
* Get default command name.
* @return Name
*/
String name();
String getName();

/**
* Run command.
*/
void run();

}
14 changes: 11 additions & 3 deletions src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ public class CommandMap {

private Map<String, Command> commands;

/**
* Constructor.
*/
public CommandMap() {
this.commands = new HashMap<>();
createCommand(new TestCommand());
}

private void createCommand(Command command) {
this.commands.put(command.name(), command);
this.commands.put(command.getName(), command);
}


/**
* Get command by default name.
* @param name
* @return Command
*/
public Command getCommand(String name) {
return commands.get(name);
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
* Class is a test command class
*/
public class TestCommand implements Command {

@Override
public String description() {
public String getDescription() {
return "This is an easter egg test command.";
}

@Override
public String name() {
public String getName() {
return "EasterEgg";
}

@Override
public void run() {
System.out.println("Let's run easter egg.");
}

}