1 changed files with 0 additions and 38 deletions
@ -1,38 +0,0 @@ |
|||
package com.example.datacollect.command; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
|
|||
import com.example.datacollect.repository.ArticleRepository; |
|||
import com.example.datacollect.view.ConsoleView; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class HistoryCommand implements Command { |
|||
private static final Logger logger = LoggerFactory.getLogger(HistoryCommand.class); |
|||
|
|||
private final ConsoleView view; |
|||
private final List<String> history; |
|||
|
|||
public HistoryCommand(ConsoleView view, List<String> history) { |
|||
this.view = view; |
|||
this.history = history; |
|||
} |
|||
|
|||
@Override |
|||
public String getName() { |
|||
return "history"; |
|||
} |
|||
|
|||
@Override |
|||
public void execute(String[] args, ArticleRepository repository) { |
|||
logger.debug("Displaying command history with {} entries", history.size()); |
|||
if (history.isEmpty()) { |
|||
view.printInfo("No command history."); |
|||
return; |
|||
} |
|||
for (int i = 0; i < history.size(); i++) { |
|||
System.out.println((i + 1) + ". " + history.get(i)); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue