@@ -71,6 +71,10 @@ static public void main(String[] args) {
7171// System.out.println(System.getProperty("user.dir"));
7272 args = new String [] {
7373 "--export" ,
74+ // "--build",
75+ // "--run",
76+ // "--present",
77+ // "--force",
7478// "--platform=windows",
7579 "--platform=macosx" ,
7680 "--bits=64" ,
@@ -188,8 +192,13 @@ public Commander(String[] args) {
188192 }
189193
190194 outputFolder = new File (outputPath );
191- if (outputFolder .exists () && !force ) {
192- complainAndQuit ("The output folder already exists. Use --force to overwrite it." , false );
195+ if (outputFolder .exists ()) {
196+ if (force ) {
197+ Base .removeDir (outputFolder );
198+ } else {
199+ complainAndQuit ("The output folder already exists. " +
200+ "Use --force to remove it." , false );
201+ }
193202 }
194203
195204 if (!outputFolder .mkdirs ()) {
@@ -215,44 +224,27 @@ public Commander(String[] args) {
215224// complainAndQuit("Sketch path must point to the main .pde file.", false);
216225
217226 } else {
218- //Sketch sketch = null;
219227 boolean success = false ;
220228
221229 JavaMode javaMode =
222230 new JavaMode (null , Base .getContentFile ("modes/java" ));
223231 try {
224232 sketch = new Sketch (pdePath , javaMode );
225- /*
226- if (task == PREPROCESS) {
233+ if (task == BUILD || task == RUN || task == PRESENT ) {
227234 JavaBuild build = new JavaBuild (sketch );
228- build.preprocess(new File(sketchFolder), true);
229- success = sketch.preprocess(new File(outputPath)) != null;
230-
231- } else*/ if (task == BUILD ) {
232- JavaBuild build = new JavaBuild (sketch );
233- String mainClassName =
234- build .build (new File (sketchPath ), outputFolder , true );
235- success = mainClassName != null ;
236-
237- } else if (task == RUN || task == PRESENT ) {
238- JavaBuild build = new JavaBuild (sketch );
239- String className = build .build (sketchFolder , outputFolder , true );
235+ File srcFolder = new File (outputFolder , "source" );
236+ String className = build .build (srcFolder , outputFolder , true );
237+ // String className = build.build(sketchFolder, outputFolder, true);
240238 if (className != null ) {
241239 success = true ;
242- Runner runner = new Runner (build , this );
243- runner .launch (task == PRESENT );
244-
240+ if (task == RUN || task == PRESENT ) {
241+ Runner runner = new Runner (build , this );
242+ runner .launch (task == PRESENT );
243+ }
245244 } else {
246245 success = false ;
247246 }
248247
249- // } else if (task == EXPORT_APPLET) {
250- // if (outputPath != null) {
251- // success = sketch.exportApplet(outputPath);
252- // } else {
253- // String target = sketchFolder + File.separatorChar + "applet";
254- // success = sketch.exportApplet(target);
255- // }
256248 } else if (task == EXPORT ) {
257249 if (outputPath == null ) {
258250 javaMode .handleExportApplication (sketch );
@@ -271,7 +263,11 @@ public Commander(String[] args) {
271263 }
272264 }
273265 }
274- System .exit (success ? 0 : 1 );
266+ if (!success ) { // error already printed
267+ System .exit (1 );
268+ }
269+ System .out .println ("Finished." );
270+ System .exit (0 );
275271
276272 } catch (SketchException re ) {
277273 statusError (re );
@@ -334,7 +330,8 @@ static void printCommandLine(PrintStream out) {
334330 out .println ();
335331 out .println ("--force The sketch will not build if the output" );
336332 out .println (" folder already exists, because the contents" );
337- out .println (" will be replaced. This option overrides." );
333+ out .println (" will be replaced. This option erases the" );
334+ out .println (" folder first. Use with extreme caution!" );
338335 out .println ();
339336 out .println ("--build Preprocess and compile a sketch into .class files." );
340337 out .println ("--run Preprocess, compile, and run a sketch." );
0 commit comments