# shellcheck shell=dash disable=SC2016
# Reference: https://gist.github.com/yunga/99d04694e2466e017c5502d7c828d4f4
# https://docs.chocolatey.org/en-us/choco/setup/#install-with-powershellexe

___x_cmd_choco___install(){
    ChocolateyInstall="${ChocolateyInstall:-"${ProgramData:+"${ProgramData}/chocolatey"}"}"
    case "$1" in
        # "Set the folder you want Chocolatey to install"
        --ChocolateyInstall)
            ChocolateyInstall="$2"
    esac

    if [ -n "$ChocolateyInstall" ]; then
        export WSLENV="${WSLENV}:ChocolateyInstall/p"
        export ChocolateyInstall="$ChocolateyInstall"
    else
        local x_=
       ___x_cmd pwsh path win_to_linux_ "$( ___x_cmd pwsh -ExecutionPolicy RemoteSigned -NoProfile -Command 'Write-Host -NoNewline $env:PROGRAMDATA' )/chocolatey"
        ChocolateyInstall="$x_"
    fi

    choco:info --ChocolateyInstall "$ChocolateyInstall" 'Installing download choco'
    ___x_cmd pwsh admin '
Set-Location $env:USERPROFILE;
Set-ExecutionPolicy Bypass -Scope Process -Force;
If ( ! ( Test-Path $PROFILE ) ) { New-Item -Force -ItemType File -Path $PROFILE; Add-Content -Path $PROFILE -Encoding UTF8 -Value "# Powershell Profile"; };
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
iex ((New-Object System.Net.WebClient).DownloadString("https://community.chocolatey.org/install.ps1"))
$env:PATH += ";$env:ChocolateyInstall\bin"
'
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned;

}



