@@ -25,22 +25,34 @@ IF EXIST "%input_cache_path%%publisher_jar%" (
2525 ) ELSE (
2626 SET " jar_location = not_found"
2727 SET " default_choice = 1"
28+ SET " default_reason = publisher not found"
2829 ECHO publisher.jar not found in input-cache or parent folder
2930 )
3031)
3132
3233
3334:: Handle command-line argument to bypass the menu
34- IF NOT " %~1 " == " " (
35- IF /I " %~1 " == " update" SET " userChoice = 1"
36- IF /I " %~1 " == " build" SET " userChoice = 2"
37- IF /I " %~1 " == " nosushi" SET " userChoice = 3"
38- IF /I " %~1 " == " notx" SET " userChoice = 4"
39- IF /I " %~1 " == " jekyll" SET " userChoice = 5"
40- IF /I " %~1 " == " clean" SET " userChoice = 6"
41- IF /I " %~1 " == " exit" SET " userChoice = 0"
42- GOTO executeChoice
43- )
35+ :: Known first arguments select a menu option; anything else is passed through to the publisher
36+ SET " extraArgs = "
37+ IF " %~1 " == " " GOTO showMenu
38+ IF /I " %~1 " == " update" SET " userChoice = 1" & GOTO parseExtra
39+ IF /I " %~1 " == " build" SET " userChoice = 2" & GOTO parseExtra
40+ IF /I " %~1 " == " nosushi" SET " userChoice = 3" & GOTO parseExtra
41+ IF /I " %~1 " == " notx" SET " userChoice = 4" & GOTO parseExtra
42+ IF /I " %~1 " == " jekyll" SET " userChoice = 5" & GOTO parseExtra
43+ IF /I " %~1 " == " clean" SET " userChoice = 6" & GOTO parseExtra
44+ IF /I " %~1 " == " exit" SET " userChoice = 0" & GOTO parseExtra
45+ :: Unknown first arg - default to build, pass all args through
46+ SET " userChoice = 2"
47+ GOTO collectArgs
48+ :parseExtra
49+ SHIFT
50+ :collectArgs
51+ IF " %~1 " == " " GOTO executeChoice
52+ SET " extraArgs = !extraArgs! %1 "
53+ SHIFT
54+ GOTO collectArgs
55+ :showMenu
4456
4557echo ---------------------------------------------------------------
4658ECHO Checking internet connection...
@@ -53,10 +65,14 @@ IF "%online_status%"=="true" (
5365 SET " latest_version = !latest_version: =! "
5466 SET " latest_version = !latest_version:~0 ,-1 ! "
5567) ELSE (
56- ECHO We're offline or tx.fhir.org is not available, can only run the publisher without TX...
68+ ECHO .
69+ ECHO *** WARNING: Working offline - this is not the normal mode.
70+ ECHO Some features (e.g. terminology rendering) will not work.
71+ ECHO .
5772 SET " txoption = -tx n/a"
5873 SET " latest_version = unknown"
5974 SET " default_choice = 4"
75+ SET " default_reason = working offline"
6076)
6177
6278echo ---------------------------------------------------------------
@@ -79,9 +95,11 @@ IF NOT "%online_status%"=="true" (
7995 IF NOT " !publisher_version! " == " !latest_version! " (
8096 ECHO An update is recommended.
8197 SET " default_choice = 1"
98+ SET " default_reason = newer version available"
8299 ) ELSE (
83100 ECHO Publisher is up to date.
84101 SET " default_choice = 2"
102+ SET " default_reason = publisher is up to date"
85103 )
86104)
87105
@@ -96,12 +114,9 @@ echo 4. Build IG - force no TX server
96114echo 5. Jekyll build
97115echo 6. Clean up temp directories
98116echo 0. Exit
99- :: echo [Press Enter for default (%default_choice%) or type an option number:]
100117echo .
101118
102- :: Using CHOICE to handle input with timeout
103- :: ECHO [Enter=Continue, 1-7=Option, 0=Exit]
104- choice /C 12345670 /N /CS /D %default_choice% /T 5 /M " Choose an option number or wait 5 seconds for default (%default_choice% ):"
119+ choice /C 12345670 /N /CS /D %default_choice% /T 5 /M " Choose an option number or wait 5 seconds for default (%default_choice% - %default_reason% ):"
105120SET " userChoice = %ERRORLEVEL% "
106121
107122
@@ -115,15 +130,12 @@ IF "%userChoice%"=="4" GOTO publish_notx
115130IF " %userChoice% " == " 5" GOTO debugjekyll
116131IF " %userChoice% " == " 6" GOTO clean
117132IF " %userChoice% " == " 0" EXIT /B
118-
119- :end
120-
121-
133+ GOTO endscript
122134
123135:debugjekyll
124136 echo Running Jekyll build...
125137 jekyll build -s temp/pages -d output
126- GOTO end
138+ GOTO endscript
127139
128140
129141:clean
@@ -152,10 +164,7 @@ GOTO end
152164 echo Removed: .\template
153165 )
154166
155- GOTO end
156-
157-
158-
167+ GOTO endscript
159168
160169
161170:downloadpublisher
@@ -198,7 +207,7 @@ IF DEFINED FORCE (
198207 GOTO download
199208)
200209
201- IF " %skipPrompts% " == " y " (
210+ IF " %skipPrompts% " == " true " (
202211 SET create = Y
203212) ELSE (
204213 SET /p create = " Download? (Y/N) "
@@ -211,7 +220,7 @@ IF /I "%create%"=="Y" (
211220GOTO done
212221
213222:upgrade
214- IF " %skipPrompts% " == " y " (
223+ IF " %skipPrompts% " == " true " (
215224 SET overwrite = Y
216225) ELSE (
217226 SET /p overwrite = " Overwrite %jarlocation% ? (Y/N) "
@@ -265,15 +274,15 @@ GOTO done
265274
266275ECHO .
267276ECHO Updating scripts
268- IF " %skipPrompts% " == " y " (
277+ IF " %skipPrompts% " == " true " (
269278 SET updateScripts = Y
270279) ELSE (
271280 SET /p updateScripts = " Update scripts? (Y/N) "
272281)
273282IF /I " %updateScripts% " == " Y" (
274283 GOTO scripts
275284)
276- GOTO end
285+ GOTO endscript
277286
278287
279288:scripts
@@ -299,27 +308,28 @@ ECHO Updating _build.bat
299308call POWERSHELL -command if ('System.Net.WebClient' -as [type]) {(new-object System.Net.WebClient).DownloadFile(\" %build_bat_url% \" ,\" _build.new.bat\" ) } else { Invoke-WebRequest -Uri " %build_bat_url% " -Outfile " _build.new.bat" }
300309if %ERRORLEVEL% == 0 goto upd_script_2
301310echo " Errors encountered during download: %errorlevel% "
302- goto end
311+ goto endscript
303312:upd_script_2
304313start copy /y " _build.new.bat" " _build.bat" ^ &^ & del " _build.new.bat" ^ &^ & exit
305314
306315
307- GOTO end
316+ GOTO endscript
308317
309318
310319:publish_once
311320
312321SET JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
313322
314323:: Debugging statements before running publisher
315- ECHO 1jar_location is: %jar_location%
324+ ECHO jar_location is: %jar_location%
316325IF NOT " %jar_location% " == " not_found" (
317- java %JAVA_OPTS% -jar " %jar_location% " -ig . %txoption% %*
326+ ECHO IG Publisher FOUND, Publishing...
327+ java %JAVA_OPTS% -jar " %jar_location% " -ig . %txoption% %extraArgs%
318328) ELSE (
319329 ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
320330)
321331
322- GOTO end
332+ GOTO endscript
323333
324334
325335
@@ -328,14 +338,14 @@ GOTO end
328338SET JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
329339
330340:: Debugging statements before running publisher
331- ECHO 3jar_location is: %jar_location%
341+ ECHO jar_location is: %jar_location%
332342IF NOT " %jar_location% " == " not_found" (
333- java %JAVA_OPTS% -jar " %jar_location% " -ig . %txoption% -no-sushi %*
343+ java %JAVA_OPTS% -jar " %jar_location% " -ig . %txoption% -no-sushi %extraArgs%
334344) ELSE (
335345 ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
336346)
337347
338- GOTO end
348+ GOTO endscript
339349
340350
341351:publish_notx
@@ -344,43 +354,33 @@ SET txoption=-tx n/a
344354SET JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
345355
346356:: Debugging statements before running publisher
347- ECHO 2jar_location is: %jar_location%
357+ ECHO jar_location is: %jar_location%
348358IF NOT " %jar_location% " == " not_found" (
349- java %JAVA_OPTS% -jar " %jar_location% " -ig . %txoption% %*
359+ java %JAVA_OPTS% -jar " %jar_location% " -ig . %txoption% %extraArgs%
350360) ELSE (
351361 ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
352362)
353363
354- GOTO end
355-
356-
364+ GOTO endscript
357365
358366
359367:publish_continuous
360368
361369SET JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
362370
363- :: Debugging statements before running publisher
364- ECHO Checking %input_cache_path% for publisher.jar
365- IF EXIST " %input_cache_path% \%publisher_jar% " (
366- java %JAVA_OPTS% -jar " %input_cache_path% \%publisher_jar% " -ig . %txoption% -watch %*
371+ ECHO jar_location is: %jar_location%
372+ IF NOT " %jar_location% " == " not_found" (
373+ java %JAVA_OPTS% -jar " %jar_location% " -ig . %txoption% -watch %extraArgs%
367374) ELSE (
368- ECHO Checking %upper_path% for publisher.jar
369- IF EXIST " ..\%publisher_jar% " (
370- java %JAVA_OPTS% -jar " ..\%publisher_jar% " -ig . %txoption% -watch %*
371- ) ELSE (
372- ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
373- )
375+ ECHO IG Publisher NOT FOUND in input-cache or parent folder. Please run _updatePublisher. Aborting...
374376)
375377
376- GOTO end
378+ GOTO endscript
377379
378380
379- :end
381+ :endscript
380382
381383:: Pausing at the end
382-
383-
384384IF NOT " %skipPrompts% " == " true" (
385385 PAUSE
386386)
0 commit comments