<beginfold id='1'><#</beginfold id='1'>
   Copied from Craft for testing syntax highlighting
<endfold id='1'>#></endfold id='1'>

<beginfold id='2'>@"</beginfold id='2'> multi
   line
   string
<endfold id='2'>"@</endfold id='2'>

$foo = "Test `u{2013} String`nwith `"escapes`""

#    this file sets some environment variables that are needed
#    for finding programs and libraries etc.
#    by Hannah von Reth <vonreth@kde.org>
#    you should copy kdesettings.ini to ..\etc\kdesettings.ini
#    and adapt it to your needs (see that file for more info)

#    this file should contain all path settings - and provide thus an environment
#    to build and run kde programs
#    based on kdeenv.bat

cls


$env:CraftRoot=[System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)

$CRAFT_ARGUMENTS = $args

&<beginfold id='3'>{</beginfold id='3'>
[version]$minPythonVersion = 3.6

function findPython([string] $name)
<beginfold id='3'>{</beginfold id='3'>
    $py = (Get-Command $name -ErrorAction SilentlyContinue)
    if ($py -and ($py | Get-Member Version) -and $py.Version -ge $minPythonVersion) <beginfold id='3'>{</beginfold id='3'>
        $env:CRAFT_PYTHON=$py.Source
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

findPython("python3")
findPython("python")

function readINI([string] $fileName)
<beginfold id='3'>{</beginfold id='3'>
   $ini = @<beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'>

  switch -regex -file $fileName <beginfold id='3'>{</beginfold id='3'>
    "^\[(.+)\]$" <beginfold id='3'>{</beginfold id='3'>
      $section = $matches[1].Trim()
      $ini[$section] = @<beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'>
    <endfold id='3'>}</endfold id='3'>
    "^\s*([^#].+?)\s*=\s*(.*)" <beginfold id='3'>{</beginfold id='3'>
      $name,$value = $matches[1..2]
      $ini[$section][$name] = $value.Trim()
    <endfold id='3'>}</endfold id='3'>
  <endfold id='3'>}</endfold id='3'>
  $ini
<endfold id='3'>}</endfold id='3'>



if(test-path -path $env:CraftRoot\..\etc\kdesettings.ini)
<beginfold id='3'>{</beginfold id='3'>
    $settings = readINI $env:CraftRoot\..\etc\kdesettings.ini
<endfold id='3'>}</endfold id='3'>
else
<beginfold id='3'>{</beginfold id='3'>
    Write-Error("$env:CraftRoot\..\etc\kdesettings.ini Does not exist")
    break
<endfold id='3'>}</endfold id='3'>
if( $CRAFT_ARGUMENTS[0] -eq "--get")
<beginfold id='3'>{</beginfold id='3'>
    Write-Host($settings[$CRAFT_ARGUMENTS[1]][$CRAFT_ARGUMENTS[2]])
    break
<endfold id='3'>}</endfold id='3'>


function prependPATH([string] $path)
<beginfold id='3'>{</beginfold id='3'>
    $env:PATH="$path{0}$env:PATH" -f [IO.Path]::PathSeparator
<endfold id='3'>}</endfold id='3'>


if( -Not $env:CRAFT_PYTHON)
<beginfold id='3'>{</beginfold id='3'>
    prependPATH $settings["Paths"]["Python"]
    $env:CRAFT_PYTHON=[IO.PATH]::COMBINE($settings["Paths"]["Python"], "python")
<endfold id='3'>}</endfold id='3'>

(& $env:CRAFT_PYTHON ([IO.PATH]::COMBINE("$env:CraftRoot", "bin", "CraftSetupHelper.py")) "--setup") |
foreach <beginfold id='3'>{</beginfold id='3'>
  if ($_ -match "=") <beginfold id='3'>{</beginfold id='3'>
    $v = $_.split("=")
    set-item -force -path "ENV:\$($v[0])"  -value "$($v[1])"
    #Write-Host("$v[0]=$v[1]")
  <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

cd "$env:KDEROOT"
<endfold id='3'>}</endfold id='3'>


function Global:craft() <beginfold id='3'>{</beginfold id='3'>
    return & $env:CRAFT_PYTHON ([IO.PATH]::COMBINE("$env:CraftRoot", "bin", "craft.py")) $args
<endfold id='3'>}</endfold id='3'>


if($args.Length -ne 0)
<beginfold id='3'>{</beginfold id='3'>
    invoke-expression -command "$args"
<endfold id='3'>}</endfold id='3'>
