11package liquidjava .api ;
22
33import java .io .File ;
4+ import java .util .Arrays ;
5+ import java .util .List ;
46
57import liquidjava .errors .ErrorEmitter ;
68import liquidjava .processor .RefinementProcessor ;
1214
1315public class CommandLineLauncher {
1416 public static void main (String [] args ) {
15- String allPath = "./liquidjava-example/src/main/java/test/currentlyTesting" ;
16-
1717 // String allPath = "C://Regen/test-projects/src/Main.java";
1818 // In eclipse only needed this:"../liquidjava-example/src/main/java/"
1919 // In VSCode needs:
2020 // "../liquidjava/liquidjava-umbrella/liquidjava-example/src/main/java/liquidjava/test/project";
21- String path = args .length == 0 ? allPath : args [0 ];
22- ErrorEmitter ee = launch (path );
21+
22+ if (args .length == 0 ) {
23+ System .out .println ("No input files or directories provided" );
24+ System .out .println ("\n Usage: ./liquidjava <...paths>" );
25+ System .out .println (" <...paths>: Paths to files or directories to be verified by LiquidJava" );
26+ System .out .println (
27+ "\n Example: ./liquidjava liquidjava-example/src/main/java/test/currentlyTesting liquidjava-example/src/main/java/testingInProgress/Account.java" );
28+ return ;
29+ }
30+ List <String > paths = Arrays .asList (args );
31+ ErrorEmitter ee = launch (paths .toArray (new String [0 ]));
2332 System .out .println (ee .foundError () ? (ee .getFullMessage ()) : ("Correct! Passed Verification." ));
2433 }
2534
@@ -28,19 +37,18 @@ public static ErrorEmitter launchTest(String path) {
2837 return ee ;
2938 }
3039
31- public static ErrorEmitter launch (String path ) {
32- System .out .println ("Running LiquidJava on: " + path );
33- ErrorEmitter ee = new ErrorEmitter ();
34-
35- // check if the path exists
36- File f = new File (path );
37- if (!f .exists ()) {
38- ee .addError ("Path not found" , "The path " + path + " does not exist" , 1 );
39- return ee ;
40- }
40+ public static ErrorEmitter launch (String ... paths ) {
41+ System .out .println ("Running LiquidJava on: " + Arrays .toString (paths ).replaceAll ("[\\ [\\ ]]" , "" ));
4142
43+ ErrorEmitter ee = new ErrorEmitter ();
4244 Launcher launcher = new Launcher ();
43- launcher .addInputResource (path );
45+ for (String path : paths ) {
46+ if (!new File (path ).exists ()) {
47+ ee .addError ("Path not found" , "The path " + path + " does not exist" , 1 );
48+ return ee ;
49+ }
50+ launcher .addInputResource (path );
51+ }
4452 launcher .getEnvironment ().setNoClasspath (true );
4553
4654 // Get the current classpath from the system
0 commit comments