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.
31 lines
973 B
31 lines
973 B
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.logging.Logger;
|
|
|
|
public class HistoryCommand11 implements Command11 {
|
|
private static final Logger logger = Logger.getLogger(HistoryCommand11.class.getName());
|
|
private final List<String> commandHistory = new ArrayList<>();
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "history";
|
|
}
|
|
|
|
@Override
|
|
public void execute(String[] args, List<Article11> articles) {
|
|
if (commandHistory.isEmpty()) {
|
|
logger.info("暂无命令历史记录");
|
|
System.out.println("暂无命令历史记录");
|
|
return;
|
|
}
|
|
logger.info("用户查看命令历史");
|
|
System.out.println("===== 命令历史 =====");
|
|
for (int i = 0; i < commandHistory.size(); i++) {
|
|
System.out.println((i + 1) + ". " + commandHistory.get(i));
|
|
}
|
|
}
|
|
|
|
public void addCommand(String cmd) {
|
|
commandHistory.add(cmd);
|
|
}
|
|
}
|