Skip to content

Commit

Permalink
Fixes #86 - Add mode flag (workflow, shell, workshop) (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Apr 11, 2024
1 parent 600763e commit 96b6271
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/main/java/com/manorrock/parrot/Parrot.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.manorrock.parrot.model.ShellScript;
import com.manorrock.parrot.model.Workflow;
import com.manorrock.parrot.model.WorkflowDispatch;
import com.manorrock.parrot.shellscript.ShellScriptGenerator;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
Expand Down Expand Up @@ -81,6 +82,11 @@ public class Parrot {
*/
private String runsOn;

/**
* Stores the mode.
*/
private String mode = "legacy";

/**
* Stores the workflows output directory.
*/
Expand Down Expand Up @@ -122,6 +128,9 @@ private void parseArguments(String[] arguments) {
if (arguments[i].equals("--runsOn")) {
runsOn = arguments[i + 1];
}
if (arguments[i].equals("--mode")) {
mode = arguments[i + 1];
}
}
}
LOGGER.log(INFO, "--- Arguments: ");
Expand All @@ -135,7 +144,23 @@ private void parseArguments(String[] arguments) {
* Run the generator.
*/
private void run() {
processDirectory(baseDirectory);
switch (mode) {
case "legacy" ->
processDirectory(baseDirectory);

case "bash" -> {
ShellScriptGenerator generator = new ShellScriptGenerator();
generator.run();
}

case "workflow" -> {
processDirectory(baseDirectory);
}

case "workshop" -> {
System.err.println("Not implemented yet");
}
}
}

/**
Expand Down Expand Up @@ -266,7 +291,7 @@ private Workflow generateWorkflow(ParrotContext context) {
permissions.put("id-token", "write");
permissions.put("contents", "read");
workflow.setPermissions(permissions);

HashMap<String, Object> jobs = new HashMap<>();
Job job = new Job();
job.setRunsOn(context.getRunsOn());
Expand Down

0 comments on commit 96b6271

Please sign in to comment.