\r
exit /b 0\r
::==============================================================================\r
+\r
+::=============================================================================\r
+:: Parse command line arguments.\r
+:: The format for the arguments is:\r
+:: Boolean: --option\r
+:: Value: --option<separator>value\r
+:: with <separator> being: space, colon, semicolon or equal sign\r
+::\r
+:: Command line usage example:\r
+:: my-batch-file.bat --build --type=release --version 123\r
+:: It will create 3 variables:\r
+:: 'build' with the value 'true'\r
+:: 'type' with the value 'release'\r
+:: 'version' with the value '123'\r
+::\r
+:: Usage:\r
+:: set "build="\r
+:: set "type="\r
+:: set "version="\r
+::\r
+:: REM Parse arguments.\r
+:: call :parse_args %*\r
+::\r
+:: if defined build (\r
+:: ...\r
+:: )\r
+:: if %type%=='release' (\r
+:: ...\r
+:: )\r
+:: if %version%=='123' (\r
+:: ...\r
+:: )\r
+::=============================================================================\r
+:parse_args\r
+ set "arg_name="\r
+ :parse_args_start\r
+ if "%1" == "" (\r
+ :: Set a seen boolean argument.\r
+ if "%arg_name%" neq "" (\r
+ set "%arg_name%=true"\r
+ )\r
+ goto :parse_args_done\r
+ )\r
+ set aux=%1\r
+ if "%aux:~0,2%" == "--" (\r
+ :: Set a seen boolean argument.\r
+ if "%arg_name%" neq "" (\r
+ set "%arg_name%=true"\r
+ )\r
+ set "arg_name=%aux:~2,250%"\r
+ ) else (\r
+ set "%arg_name%=%1"\r
+ set "arg_name="\r
+ )\r
+ shift\r
+ goto :parse_args_start\r
+\r
+:parse_args_done\r
+exit /b 0\r
+::==============================================================================\r