diff --git a/runsample b/runsample index 7610f943d..bdc31708a 100755 --- a/runsample +++ b/runsample @@ -6,11 +6,10 @@ task=$1 shift 1 -if [ ! -d "samples/${task}" ]; then - echo "Unknown sample ${task}" +if [ -z "${task}" ] || [ ! -d "samples/${task}" ] +then + echo "Unknown sample: '${task}'" exit 1 fi -./gradlew --quiet :samples:${task}:installDist - -./samples/${task}/build/install/${task}/bin/${task} "$@" +./gradlew --quiet ":samples:${task}:installDist" && "./samples/${task}/build/install/${task}/bin/${task}" "$@" diff --git a/runsample.bat b/runsample.bat new file mode 100755 index 000000000..e5178b142 --- /dev/null +++ b/runsample.bat @@ -0,0 +1,24 @@ +@if "%DEBUG%"=="" @echo off +:: Run one of the samples. +:: The first argument must be the name of the sample task (e.g. echo). +:: Any remaining arguments are forwarded to the sample's argv. + +if "%OS%"=="Windows_NT" setlocal EnableDelayedExpansion + +set TASK=%~1 + +set SAMPLE=false +if defined TASK if not "!TASK: =!"=="" if exist "samples\%TASK%\*" set SAMPLE=true + +if "%SAMPLE%"=="false" ( + echo Unknown sample: '%TASK%' + exit /b 1 +) + +set ARGS=%* +set ARGS=!ARGS:*%1=! +if "!ARGS:~0,1!"==" " set ARGS=!ARGS:~1! + +call gradlew --quiet ":samples:%TASK%:installDist" && call "samples\%TASK%\build\install\%TASK%\bin\%TASK%" %ARGS% + +if "%OS%"=="Windows_NT" endlocal