I have .bat code like this. For example:
@ECHO OFF setlocal EnableDelayedExpansion call :setESC set arg1=%1 set "noArgs=true" for %%a in (%*) do ( if not %%a == "" ( :: if it is not empty arguments. set "noArgs=false" ) ) if "%noArgs%" == "true" ( if "%arg1%" == "" ( :: it is empty args AND argument1 (/arg) is empty :: set default argument here. <----------- set "%%1=build" ) ) :: for debugging. echo all args: %* :end. :: run external command (gulp). gulp --cwd "/my/project" %*
From CLI, If I enter the command
gulpbat build it will be call to
gulp build. But if I call
gulpbat, it will be response Task never defined: default.
I would like to add default task to
build if it is missing in the command line and will be use in
I have tried these but failed.
set "%1=build" :: error: The syntax of the command is incorrect. set "%~1=build" :: error: The syntax of the command is incorrect. set "%%1=build" :: not working in %*