@echo off
SETLOCAL EnableDelayedExpansion
echo %cmdcmdline% | findstr /i /c:"%~nx0" >NUL && set iscommandline=1
echo %PSModulePath% | findstr /i /c:"%USERPROFILE%" >NUL && set ispowershell=1
cd /D "%~dp0"

SET UrlToConvert=
IF "%~1"=="" (
    echo Absolute URL not specified.
    set /p UrlToConvert=Insert absolute URL to convert: 
    IF "!UrlToConvert!"=="" (
        echo Absolute URL is required!
        exit /b 1
    ) ELSE (
        echo Using absolute URL: !UrlToConvert!
        set AbsoluteUrl="!UrlToConvert!"
    )
) ELSE (
    echo Using absolute URL: %~1
    set AbsoluteUrl=%~1
)

@powershell -NoProfile -ExecutionPolicy Bypass -Command .\scripts\convert-url-to-elix.ps1 -AbsoluteUrl '%AbsoluteUrl%'

IF DEFINED iscommandline IF NOT DEFINED ispowershell pause
ENDLOCAL
