Skip to content

Commit

Permalink
allow force download
Browse files Browse the repository at this point in the history
  • Loading branch information
endixk committed Feb 3, 2025
1 parent cf9cfe3 commit 39d48d6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/module/DownloadModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class DownloadModule {
private final String[] args;
private String target, dir = PathConfig.JarPath;
private boolean dirGiven = false;
private boolean force = false;

public DownloadModule(String[] args) {
this.args = args;
Expand All @@ -46,6 +47,7 @@ private int parseArguments() {
opts.addOption(null, "test", false, "for test");

opts.addOption("t", "target", true, "download target");
opts.addOption("f", "force", false, "force download");
opts.addOption("d", "dir", true, "download directory");
opts.addOption("c", "check", false, "check files");

Expand Down Expand Up @@ -115,6 +117,7 @@ private int parseArguments() {
ExceptionHandler.handle(ExceptionHandler.INVALID_TARGET);
return 1;
}
if(cmd.hasOption("f")) force = true;
return 0;
}

Expand Down Expand Up @@ -145,6 +148,7 @@ private void printManual() {
System.out.println(ANSIHandler.wrapper(" Argument Description", 'c'));
System.out.println(ANSIHandler.wrapper(" -d STR Download directory [auto]", 'x'));
System.out.println(ANSIHandler.wrapper(" -c Check download status", 'x'));
System.out.println(ANSIHandler.wrapper(" -f Force download", 'x'));
System.out.println();

UFCGMainPipeline.printGeneral();
Expand Down Expand Up @@ -181,7 +185,7 @@ private void download() throws IOException {
boolean ping = internetConnection();
if(PathConfig.EnvironmentPathSet && !dirGiven) dir = PathConfig.EnvironmentPath;

if(!ping) {
if(!ping && !force) {
ExceptionHandler.handle(ExceptionHandler.NO_INTERNET);
return;
}
Expand Down

0 comments on commit 39d48d6

Please sign in to comment.