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.
 
 

34 lines
948 B

package com.crawler.command;
import java.util.List;
public class ListCommand extends BaseCommand {
@Override
public String getName() {
return "list";
}
@Override
public String getDescription() {
return "查看使用过的指令历史";
}
@Override
public void execute() {
List<String> historyList = history.getHistory();
System.out.println("========================================");
System.out.println("指令历史记录:");
System.out.println("========================================");
if (historyList.isEmpty()) {
System.out.println("暂无指令记录");
} else {
for (int i = 0; i < historyList.size(); i++) {
System.out.printf("[%d] %s%n", i + 1, historyList.get(i));
}
}
System.out.println("========================================");
}
}