File tree Expand file tree Collapse file tree
lib/koans-lib/src/com/sandwich/koan/cmdline/behavior Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ ClassArg.success=
7878
7979Clear.args = -clear
8080Clear.description =Clears compiled artifacts and stored file system timestamps.
81- Clear.error =Unable to delete filesystem_hashes.dat or bin directory.
81+ Clear.error =Unable to delete filesystem_hashes.dat or application data or class directory.
8282Clear.success =Classes and file system timestamps deleted successfully.
8383
8484Debug.args = -debug, debug, d
Original file line number Diff line number Diff line change @@ -10,10 +10,7 @@ javac -version
1010if ERRORLEVEL 3 goto no_javac
1111java -version
1212if ERRORLEVEL 1 goto no_java
13- mkdir " %~dp0 \app\data"
14- mkdir " %~dp0 \app\bin"
1513cls
16- echo " %~dp0 app\bin%CLASSPATH% "
1714java -Dapplication.basedir=" %~dp0 " " -classpath %CLASSPATH% com.sandwich.koan.runner.AppLauncher %1 %2 %3 %4 %5 %6 %7 %8 %9
1815
1916goto end
Original file line number Diff line number Diff line change 1+ #! /bin/bash
12DIR=" $( cd -P " $( dirname " $0 " ) " && pwd ) "
2- mkdir -p " $DIR " /app/data
3- mkdir -p " $DIR " /app/bin
3+ mkdir -p " $DIR " " /app/data"
4+ mkdir -p " $DIR " " /app/bin"
45exitOnError ()
56{
6- rc=$?
7- if [[ $rc != 0 ]] ; then
8- echo ${1} ' is missing from your PATH.'
9- exit $rc
10- fi
7+ rc=$?
8+ if [[ $rc != 0 ]] ; then
9+ echo ${1} ' is missing from your PATH.'
10+ exit $rc
11+ fi
1112}
1213
1314buildClasspath ()
1415{
1516 appDir=$1
1617 classpath=$appDir /bin
17- IFS=$' \n '
18+ IFS=$' \n '
1819
19- for jar in $appDir /lib/* ; do
20+ for jar in $appDir /lib/*
21+ do
2022 classpath=$classpath :$jar
2123 done
2224}
@@ -25,4 +27,5 @@ exitOnError 'javac'
2527java -version > /dev/null 2>&1
2628exitOnError ' java'
2729buildClasspath " $DIR " /app
28- java -Dapplication.basedir=\" $DIR \" -classpath \" $classpath \" com.sandwich.koan.runner.AppLauncher " $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 "
30+ cmd=" java -Dapplication.basedir=\" $DIR \" -classpath \" $classpath \" com.sandwich.koan.runner.AppLauncher " $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 " "
31+ eval $cmd
Original file line number Diff line number Diff line change 11package com .sandwich .koan .cmdline .behavior ;
22
33import java .io .File ;
4+ import java .util .ArrayList ;
5+ import java .util .Arrays ;
6+ import java .util .List ;
47
8+ import com .sandwich .koan .util .ApplicationUtils ;
59import com .sandwich .util .io .directories .DirectoryManager ;
610
711public class Clear extends AbstractArgumentBehavior {
812
13+ List <String > files = Arrays .asList (
14+ DirectoryManager .getDataFile (),
15+ DirectoryManager .getBinDir (),
16+ DirectoryManager .getDataDir ());
17+
918 public void run (String ... values ) throws Exception {
10- new File (DirectoryManager .getDataFile ()).delete ();
11- new File (DirectoryManager .getBinDir ()).delete ();
12- new File (DirectoryManager .getDataDir ()).delete ();
19+ List <File > unableToDelete = new ArrayList <File >();
20+ for (String fileName : files ){
21+ File file = new File (fileName );
22+ if (file .exists ()){
23+ if (file .delete ()){
24+ ApplicationUtils .getPresenter ().displayMessage (file .getAbsolutePath () + " deleted successfully." );
25+ }else {
26+ unableToDelete .add (file );
27+ ApplicationUtils .getPresenter ().displayError (file .getAbsolutePath () + " was NOT DELETED. Please delete manually." );
28+ }
29+ }else {
30+ ApplicationUtils .getPresenter ().displayMessage (file .getAbsolutePath () + " does not exist. Skipping." );
31+ }
32+ }
33+ throw new RuntimeException ("Unable to delete: " +unableToDelete +" see output for details." );
1334 }
1435
1536}
You can’t perform that action at this time.
0 commit comments