/
RPGtoPUML.java
65 lines (53 loc) · 2.27 KB
/
RPGtoPUML.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.strumenta.rpg;
import com.strumenta.rpg.transform.ModelToModel;
import com.strumenta.rpg.transform.ModelToSource;
import com.strumenta.rpg.transform.SourceToModel;
import org.apache.commons.cli.*;
import java.io.File;
/**
* Main class for the RPG to PlantUML conversion tool.
* This command-line application takes RPG source code as input
* and generates a PlantUML diagram as output. The conversion
* process involves multiple stages of transformation.
*/
public class RPGtoPUML {
/**
* The main method for the RPGtoPUML command-line application.
* It parses command-line arguments for input and output file paths
* and orchestrates the conversion process.
*
* @param args Command-line arguments, expecting input and output file paths.
*/
public static void main(String[] args) {
Options options = new Options();
Option input = new Option("i", "input", true, "input file path");
input.setRequired(true);
options.addOption(input);
Option output = new Option("o", "output", true, "output file path");
output.setRequired(true);
options.addOption(output);
CommandLineParser parser = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd;
try {
cmd = parser.parse(options, args);
File inputFile = new File(cmd.getOptionValue("input"));
File outputFile = new File(cmd.getOptionValue("output"));
try {
Pipeline pipeline = new Pipeline(
new SourceToModel(inputFile,outputFile), // Transform the RPG source code to the model (AST)
new ModelToModel(inputFile,outputFile), // Transform the RPG Model (AST) to the PlantUML model (AST)
new ModelToSource(inputFile,outputFile) // Transform the RPG Model (AST) to the PlantUML model (AST)
);
pipeline.run();
} catch (Exception e) {
System.out.println(e.getMessage());
System.exit(1);
}
// Process the input file path
} catch (ParseException e) {
formatter.printHelp("RPGtoPUML", options);
System.exit(1);
}
}
}