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
938 B
33 lines
938 B
package com.example.datacollect.command;
|
|
|
|
import com.example.datacollect.repository.ArticleRepository;
|
|
import com.example.datacollect.view.ConsoleView;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
public class ListCommand implements Command {
|
|
|
|
// 1. 添加 Logger 成员
|
|
private static final Logger logger = LoggerFactory.getLogger(ListCommand.class);
|
|
|
|
private final ConsoleView view;
|
|
|
|
public ListCommand(ConsoleView view) {
|
|
this.view = view;
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "list";
|
|
}
|
|
|
|
@Override
|
|
public void execute(String[] args, ArticleRepository repository) {
|
|
logger.info("正在执行 list 命令,准备展示已抓取的文章列表。");
|
|
|
|
// 保留原有的视图输出
|
|
view.display(repository.getAll());
|
|
|
|
logger.debug("当前仓库中共有 {} 篇文章已加载至视图。", repository.getAll().size());
|
|
}
|
|
}
|
|
|