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.
49 lines
1.5 KiB
49 lines
1.5 KiB
package command;
|
|
|
|
import strategy.CrawlerStrategy;
|
|
import strategy.StrategyFactory;
|
|
import view.ConsoleView;
|
|
import java.util.List;
|
|
import repository.PaperRepository;
|
|
|
|
public class PlatformCommand implements Command {
|
|
private StrategyFactory strategyFactory;
|
|
private ConsoleView view;
|
|
|
|
public PlatformCommand(ConsoleView view, StrategyFactory strategyFactory) {
|
|
this.view = view;
|
|
this.strategyFactory = strategyFactory;
|
|
}
|
|
|
|
@Override
|
|
public void execute(String[] args, PaperRepository repository) {
|
|
List<CrawlerStrategy> strategies = strategyFactory.getAllStrategies();
|
|
|
|
if (strategies.isEmpty()) {
|
|
view.showInfo("暂不支持任何论文平台");
|
|
} else {
|
|
view.showInfo("当前支持 " + strategies.size() + " 个论文平台:");
|
|
System.out.println();
|
|
|
|
int index = 1;
|
|
for (CrawlerStrategy strategy : strategies) {
|
|
System.out.println(index + ". " + strategy.getPlatformName());
|
|
index++;
|
|
}
|
|
|
|
System.out.println();
|
|
view.showInfo("使用示例: crawl <平台URL>");
|
|
view.showInfo("例如: crawl https://arxiv.org/search/?query=machine+learning");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getDescription() {
|
|
return "显示支持的论文平台列表";
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "platforms";
|
|
}
|
|
}
|
|
|