You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
934 B

package com.example.datacollect.command;
import com.example.datacollect.repository.ArticleRepository;
import com.example.datacollect.view.ConsoleView;
import java.util.List;
public class HistoryCommand implements Command {
private final ConsoleView view;
private final List<String> commandHistory;
public HistoryCommand(ConsoleView view, List<String> commandHistory) {
this.view = view;
this.commandHistory = commandHistory;
}
@Override
public String getName() {
return "history";
}
@Override
public void execute(String[] args, ArticleRepository repository) {
if (commandHistory.isEmpty()) {
view.printInfo("No command history.");
return;
}
view.printInfo("Command history:");
for (int i = 0; i < commandHistory.size(); i++) {
view.printInfo((i + 1) + ". " + commandHistory.get(i));
}
}
}