anchor.diff:    exit /B %ERRORLEVEL%
   
   :publish
  -  echo Not yet implemented for Windows
  -  exit /B 1
  +  call :capture_instances svc "http-gateway"
  +  if "%svc%"=="[]" (
  +    echo Unable to locate the http-gateway
  +    exit /B 1
  +  )
  +
  +  call :capture_jsonpath svc_type "http-gateway" "{.items[0].spec.type}"
  +  if [%svc_type%]==[NodePort] (
  +    call :capture_cmd address "minikube ip"
  +    call :capture_jsonpath port "http-gateway" "{.items[0].spec.ports[?(@.name == 'http')].nodePort}"
  +    goto do_curl
  +  )
  +
  +  call :capture_jsonpath address "http-gateway" "{.items[0].status.loadBalancer.ingress[0].ip}"
  +  if [%address%]==[] (
  +    echo External IP is not yet available, try in a few ...
  +    exit /B 1
  +  )
  +  call :capture_jsonpath port "http-gateway" "{.items[0].spec.ports[?(@.name == 'http')].port}"
  +
  +  :do_curl
  +  if [%TOPIC_IN%]==[] set TOPIC_IN=%FUNCTION%
  +  if [%PUB_COUNT%]==[] (
  +      set count=1
  +  ) else (
  +      set count=%PUB_COUNT%
  +  )
  +  if [%PUB_PAUSE%]==[] (
  +      set pause=0
  +  ) else (
  +      set pause=%PUB_PAUSE%
  +  )
  +  for /L %%i in (1,1,%count%) do call :do_post_content %%i
  +  echo.
  +
  +  exit /B %ERRORLEVEL%
   
   :version
     echo riff version %RIFF_VERSION%
     exit /B 0
   
  +:write_dockerfile
  +  if exist %FNDOCKER% (
  +    if "%FORCE%"=="true" (
  +      del %FNDOCKER%
  +    ) else (
  +      echo Docker file already exists in %FNDIR%
  +      exit /B %ERRORLEVEL%
  +    )
  +  )
  +  if "%FNLANG%"=="shell" (
  +    echo FROM projectriff/%FNLANG%-function-invoker:%RIFF_VERSION% >> %FNDOCKER%
  +    echo ARG FUNCTION_URI="${FNFILE}" >> %FNDOCKER%
  +    echo ENV FUNCTION_URI ${FUNCTION_URI} >> %FNDOCKER%
  +    echo ADD %ARTRELPATH% / >> %FNDOCKER%
  +  )
  +  if "%FNLANG%"=="java" (
  +    echo FROM projectriff/%FNLANG%-function-invoker:%RIFF_VERSION% >> %FNDOCKER%
  +    echo ARG FUNCTION_JAR=/functions/%FNFILE% >> %FNDOCKER%
  +    echo ARG FUNCTION_CLASS=%FNHANDLER% >> %FNDOCKER%
  +    echo ENV FUNCTION_URI file://${FUNCTION_JAR}?handler=${FUNCTION_CLASS} >> %FNDOCKER%
  +    echo ADD %ARTRELPATH% ${FUNCTION_JAR} >> %FNDOCKER%
  +  )
  +  if "%FNLANG%"=="node" (
  +    echo FROM projectriff/%FNLANG%-function-invoker:%RIFF_VERSION% >> %FNDOCKER%
  +    echo ENV FUNCTION_URI /functions/%FNFILE% >> %FNDOCKER%
  +    echo ADD %ARTRELPATH% ${FUNCTION_URI} >> %FNDOCKER%
  +  )
  +  if "%FNLANG%"=="python" (
  +    echo FROM projectriff/python2-function-invoker:%RIFF_VERSION% >> %FNDOCKER%
  +    echo ARG FUNCTION_MODULE=%FNFILE% >> %FNDOCKER%
  +    echo ARG FUNCTION_HANDLER=%FNHANDLER% >> %FNDOCKER%
  +    echo ENV FUNCTION_URI file:///${FUNCTION_MODULE}?handler=${FUNCTION_HANDLER} >> %FNDOCKER%
  +    echo ADD %ARTRELPATH% / >> %FNDOCKER%
  +    echo ADD %ARTRELDIR%/requirements.txt / >> %FNDOCKER%
  +    echo RUN pip install --upgrade pip ^&^& pip install -r /requirements.txt >> %FNDOCKER%
  +  )
  +  exit /B %ERRORLEVEL%
  +
  +:write_func_yaml
  +  if exist %FNDEF% (
  +    if "%FORCE%"=="true" (
  +      del %FNDEF%
  +    ) else (
  +      echo Function definition file already exists in %FNDIR%
  +      exit /B %ERRORLEVEL%
  +    )
  +  )
  +  echo apiVersion: projectriff.io/v1 >> %FNDEF%
  +  echo kind: Function >> %FNDEF%
  +  echo metadata: >> %FNDEF%
  +  echo   name: %FUNCTION% >> %FNDEF%
  +  echo spec: >> %FNDEF%
  +  echo   protocol: %FNPROT% >> %FNDEF%
  +  echo   input: %TOPIC_IN% >> %FNDEF%
  +  if Not "%TOPIC_OUT%"=="" (
  +    echo   output: %TOPIC_OUT% >> %FNDEF%
  +  )
  +  echo   container: >> %FNDEF%
  +  echo     image: %USERACCT%/%FUNCTION%:%VERSION% >> %FNDEF%
  +  exit /B %ERRORLEVEL%
  +
  +:write_topics_yaml
  +  if exist %FNTOPICS% (
  +    if "%FORCE%"=="true" (
  +      del %FNTOPICS%
  +    ) else (
  +      echo Topics definition file already exists in %FNDIR%
  +      exit /B %ERRORLEVEL%
  +    )
  +  )
  +  echo apiVersion: projectriff.io/v1 >> %FNTOPICS%
  +  echo kind: Topic >> %FNTOPICS%
  +  echo metadata: >> %FNTOPICS%
  +  echo   name: %TOPIC_IN% >> %FNTOPICS%
  +  echo spec: >> %FNTOPICS%
  +  echo   partitions: 1 >> %FNTOPICS%
  +  if Not "%TOPIC_OUT%"=="" (
  +    echo --- >> %FNTOPICS%
  +    echo apiVersion: projectriff.io/v1 >> %FNTOPICS%
  +    echo kind: Topic >> %FNTOPICS%
  +    echo metadata: >> %FNTOPICS%
  +    echo   name: %TOPIC_OUT% >> %FNTOPICS%
  +    echo spec: >> %FNTOPICS%
  +    echo   partitions: 1 >> %FNTOPICS%
  +  )
  +  exit /B %ERRORLEVEL%
  +
  +:do_post_content
  +if "%PUB_EVAL%"=="true" (
  +  call :capture_echo _message %PUB_DATA% %1
  +) else (
  +  set _message=%PUB_DATA%
  +)
  +if "%PUB_REPLY%"=="true" (
  +  curl -H "Content-Type: text/plain" -X POST http://%address%:%port%/requests/%TOPIC_IN% -d %_message%
  +) else (
  +  curl -H "Content-Type: text/plain" -X POST http://%address%:%port%/messages/%TOPIC_IN% -d %_message%
  +)
  +timeout /t %pause% /nobreak > NUL
  +exit /B %ERRORLEVEL%
  +
  +:capture_echo
  +set i=%3
  +for /f "tokens=* usebackq" %%f in (`echo %2`) do (
  +  set %1=%%f
  +)
  +exit /B %ERRORLEVEL%
  +
  +:capture_cmd
  +for /f "tokens=* usebackq" %%f in (`%~2`) do (
  +  set %1=%%f
  +)
  +exit /B %ERRORLEVEL%
  +
  +:capture_instances
  +set _tmp_file=%tmp%riff-%random%.txt
  +kubectl get svc -l component=%~2 -o jsonpath="{.items}" >  %_tmp_file%
  +for /f "delims= tokens=1" %%x in (%_tmp_file%) do set %1=%%x
  +del %_tmp_file%
  +exit /B %ERRORLEVEL%
  +
  +:capture_jsonpath
  +set _tmp_file=%tmp%\riff-%random%.txt
  +set _kcmd=kubectl get svc -l component=%~2 -o jsonpath=%3
  +%_kcmd% > %_tmp_file%
  +for /f "delims= tokens=1" %%x in (%_tmp_file%) do set %1=%%x
  +del %_tmp_file%
  +exit /B %ERRORLEVEL%
   
   :: help texts
   :print_usage
  
positive.code: echo.
  echo Usage:
  echo.
  echo   riff build -n ^<name^> -v ^<version^> -f ^<path^>
  echo.
  echo Options:
  echo.
  echo   -n, --name: the name of the function (defaults to the name of the current directory)
  echo   -v, --version: the version of the function (defaults to 0.0.1)
  echo   -f, --filename: filename, directory, or URL for the code or resource (defaults to the current directory)
  echo.
  exit /B 0
  
  :print_create_usage
  echo.
  echo This feature is not yet available for Windows. 
  echo.
  echo Contributions are welcome, refer to https://github.com/projectriff/riff/issues/234
  echo.
  exit /B 0
  
  
negative.code: echo Usage:
  echo.
  echo   riff delete -n ^<name^>
  echo     or
  echo   riff delete -f ^<path^> --all
  echo.
  echo Options:
  echo.
  echo   -n, --name: the name of the function (defaults to the name of the current directory)
  echo   -f, --filename: filename, directory, or URL for the resource definition[s] (defaults to the current directory)
  echo   --all: delete all resources including topics, not just the function resource
  echo.
  exit /B 0
  
  