Skip to content

Commit

Permalink
Update the application launcher to handle drag-n-drop of multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
psndcsrv committed Mar 19, 2021
1 parent e6bcee7 commit 6ff5877
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/main/java/com/ungerdesign/ifit/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

public class Application {
Expand All @@ -21,7 +23,27 @@ public static void main(String[] args) {
}

Sport sport = Sport.lookup(args[0]);
String filename = args[1];
List<String> filenames = Arrays.asList(args[1].split(" "));

LOG.info("Got files ({}): {}", filenames.size(), filenames);

boolean hasErrors = false;

for (String filename : filenames) {
try {
handleFile(sport, filename);
} catch (RuntimeException e) {
LOG.error("Failed to process file: {}", filename, e);
hasErrors = true;
}
}

if (hasErrors) {
System.exit(1);
}
}

private static void handleFile(Sport sport, String filename) {
String lowercaseFilename = filename.toLowerCase(Locale.ROOT);

File csvFile;
Expand Down

0 comments on commit 6ff5877

Please sign in to comment.