Skip to content

Commit f48f7bc

Browse files
committed
Add an cli option to compress a project
1 parent fa5734c commit f48f7bc

File tree

1 file changed

+16
-0
lines changed
  • tmc-langs-cli/src/main/java/fi/helsinki/cs/tmc/langs/cli

1 file changed

+16
-0
lines changed

tmc-langs-cli/src/main/java/fi/helsinki/cs/tmc/langs/cli/Main.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.io.IOException;
2424
import java.nio.file.FileVisitResult;
25+
import java.nio.file.Files;
2526
import java.nio.file.Path;
2627
import java.nio.file.Paths;
2728
import java.util.Arrays;
@@ -54,6 +55,7 @@ public final class Main {
5455
+ " Commands:\n"
5556
+ " checkstyle --exercisePath --outputPath --locale"
5657
+ " Run checkstyle or similar plugin to project if applicable.\n"
58+
+ " compress-project --exercisePath --outputPath\n"
5759
+ " help"
5860
+ " Display help information.\n"
5961
+ " prepare-solutions --exercisePath --outputPath"
@@ -118,6 +120,9 @@ private static void run(String command) {
118120
case "checkstyle":
119121
runCheckCodeStyle();
120122
break;
123+
case "compress-project":
124+
runCompressProject();
125+
break;
121126
case "scan-exercise":
122127
runScanExercise();
123128
break;
@@ -166,6 +171,17 @@ private static Path getOutputPathFromArgs() {
166171
throw new IllegalStateException("No " + OUTPUT_PATH + " provided");
167172
}
168173

174+
private static void runCompressProject() {
175+
Path exercisePath = getExercisePathFromArgs();
176+
Path outputPath = getOutputPathFromArgs();
177+
try {
178+
byte[] compressed = executor.compressProject(exercisePath);
179+
Files.write(outputPath, compressed);
180+
} catch (IOException | NoLanguagePluginFoundException e) {
181+
e.printStackTrace();
182+
}
183+
}
184+
169185
private static void runCheckCodeStyle() {
170186
ValidationResult validationResult = null;
171187
try {

0 commit comments

Comments
 (0)