Skip to content

Commit

Permalink
#16 - auto-download payloads for initial profile runs
Browse files Browse the repository at this point in the history
  • Loading branch information
endixk committed Aug 7, 2023
1 parent fec70de commit 75265d5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/pipeline/ModuleHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,27 @@
import module.TreeModule;
import module.DownloadModule;

import java.util.Arrays;
import java.util.List;

public class ModuleHandler {
private final int module;
private final String[] args;
public final boolean help;

public ModuleHandler(int module, String[] args) {
this.module = module;
this.args = args;
List<String> argList = Arrays.asList(args);
if(argList.contains("-h") || argList.contains("--help")) {
Prompt.SUPPRESS = true;
help = true;
} else {
help = false;
}
if(module == UFCGMainPipeline.MODULE_DOWNLOAD && argList.contains("-c")) {
Prompt.SUPPRESS = true;
}
}

private void handle_no_module() {
Expand Down
21 changes: 20 additions & 1 deletion src/pipeline/UFCGMainPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,28 @@ public static void main(String[] args) {
/* Module parsing */
int module = parseModule(args);
GenericConfig.setModule(module);

printLogo();
ModuleHandler mh = new ModuleHandler(module, args);

if(!STABLE && module != NO_MODULE) {
Prompt.warn("This is an unstable version. Use at your own risk. Please report any bugs or errors.");
}

/* Check environment for profile modules */
if(module == MODULE_PROFILE || module == MODULE_PROFILE_RNA || module == MODULE_PROFILE_PRO) {
if(!mh.help && !PathConfig.EnvironmentPathSet) {
Prompt.warn("Could not set environment path. Downloading resources to the auto-detected path.");
Prompt.warn("This may happen if this is your first launch after installation or update.");

String[] dargs = {"-t", "minimum"};
ModuleHandler dh = new ModuleHandler(MODULE_DOWNLOAD, dargs);
dh.handle();

PathConfig.setEnvironmentPath(jarPath.substring(0, jarPath.lastIndexOf("/")));
}
}

mh.handle();
}
catch(Exception e) {
Expand Down

0 comments on commit 75265d5

Please sign in to comment.