mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-10 08:52:55 +00:00
add wildcard support from commandline
This commit is contained in:
parent
e4d3f1a141
commit
68e1f59ccc
5
pom.xml
5
pom.xml
@ -93,6 +93,11 @@
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.8.0</version> <!-- Check for the latest version -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -10,9 +10,13 @@ import de.maishai.typedast.typedclass.TypedClass;
|
||||
import de.maishai.typedast.typedclass.TypedProgram;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Handler;
|
||||
@ -137,9 +141,27 @@ public class Compiler {
|
||||
|
||||
List<String> sourcePaths = new ArrayList<>();
|
||||
for (String arg : cmd.getArgs()) {
|
||||
String sourcePath = arg.endsWith(JAVA_FILE_EXTENSION) ? arg : arg + JAVA_FILE_EXTENSION;
|
||||
sourcePaths.add(sourcePath);
|
||||
if (arg.contains("*")) {
|
||||
sourcePaths.addAll(expandWildcards(arg));
|
||||
} else {
|
||||
String sourcePath = arg.endsWith(JAVA_FILE_EXTENSION) ? arg : arg + JAVA_FILE_EXTENSION;
|
||||
sourcePaths.add(sourcePath);
|
||||
}
|
||||
}
|
||||
generateByteCodeFilesFromFiles(sourcePaths);
|
||||
}
|
||||
|
||||
private static List<String> expandWildcards(String pattern) {
|
||||
List<String> matchingFiles = new ArrayList<>();
|
||||
try {
|
||||
File dir = new File(".");
|
||||
Collection<File> files = FileUtils.listFiles(dir, new WildcardFileFilter(pattern), null);
|
||||
for (File file : files) {
|
||||
matchingFiles.add(file.getPath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.severe("Error expanding wildcards: " + e.getMessage());
|
||||
}
|
||||
return matchingFiles;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user