Skip to content

Commit 84a403b

Browse files
committed
TcMenu CLI: Add output dir option
1 parent d86ace9 commit 84a403b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

tcMenuGenerator/src/main/java/com/thecoderscorner/menu/editorui/cli/CodeGeneratorCommand.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.thecoderscorner.menu.domain.state.MenuTree;
44
import com.thecoderscorner.menu.editorui.MenuEditorApp;
55
import com.thecoderscorner.menu.editorui.generator.CodeGeneratorOptions;
6+
import com.thecoderscorner.menu.editorui.generator.ProjectSaveLocation;
67
import com.thecoderscorner.menu.editorui.generator.core.CreatorProperty;
78
import com.thecoderscorner.menu.editorui.generator.plugin.CodePluginItem;
89
import com.thecoderscorner.menu.editorui.generator.plugin.DefaultXmlPluginLoader;
@@ -50,6 +51,9 @@ public class CodeGeneratorCommand implements Callable<Integer> {
5051
@CommandLine.Option(names = {"-v", "--verbose"}, description = "verbose logging")
5152
private boolean verbose;
5253

54+
@CommandLine.Option(names = {"-o", "--output-dir"}, description = "output directory")
55+
private String outputDir;
56+
5357
@Override
5458
public Integer call() {
5559
try {
@@ -89,7 +93,15 @@ public Integer call() {
8993
plugins.add(getPluginOrDefault(allPlugins, project.getOptions().getLastThemeUuid(), DEFAULT_THEME_PLUGIN, propMap));
9094
}
9195

92-
var location = Paths.get(loadedProjectFile.getParent());
96+
// Override output dir settings from project file if specified as a parameter.
97+
Path location;
98+
location = (outputDir != null)
99+
? Paths.get(outputDir)
100+
: Paths.get(loadedProjectFile.getParent());
101+
if (outputDir != null) {
102+
project.getOptions().setSaveLocation(ProjectSaveLocation.ALL_TO_CURRENT);
103+
}
104+
93105
codeGen.setLoggerFunction((level, s) -> {
94106
if(verbose) System.out.format("Gen: %s: %s\n", level, s);
95107
});

tcMenuGenerator/src/main/java/com/thecoderscorner/menu/editorui/generator/CodeGeneratorOptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public ProjectSaveLocation getSaveLocation() {
129129
return saveLocation;
130130
}
131131

132+
public void setSaveLocation(ProjectSaveLocation saveLocation) {
133+
this.saveLocation = saveLocation;
134+
}
135+
132136
public boolean isUseCppMain() {
133137
return useCppMain;
134138
}

0 commit comments

Comments
 (0)