1 changed files with 0 additions and 33 deletions
@ -1,33 +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; |
|
||||
|
|
||||
public class LoadCommand implements Command { |
|
||||
private static final Logger logger = LoggerFactory.getLogger(LoadCommand.class); |
|
||||
private final ConsoleView view; |
|
||||
|
|
||||
public LoadCommand(ConsoleView view) { |
|
||||
this.view = view; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public String getName() { |
|
||||
return "load"; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void execute(String[] args, ArticleRepository repository) { |
|
||||
String filePath = args.length > 1 ? args[1] : "articles.txt"; |
|
||||
try { |
|
||||
repository.loadFromFile(filePath); |
|
||||
view.printSuccess("Loaded " + repository.size() + " articles from " + filePath); |
|
||||
} catch (Exception e) { |
|
||||
view.printError("Failed to load: " + e.getMessage()); |
|
||||
logger.error("Failed to load articles from file", e); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue