#Requires -Version 7.2 [CmdletBinding()] param( [Parameter(Mandatory)][ValidateSet('init','validate','dry-run','start','resume','status','pause','retry','current','logs','recover','configure','setup','auth','auth-status','qualify','approve','prepare','prepare-entry','key','enable-unattended')][string]$Command, [string]$ControlRoot, [string]$Repository, [string]$Stage, [string]$Manifest, [string]$Python = 'python' ) $ErrorActionPreference = 'Stop' if (-not $ControlRoot) { $ControlRoot = if (Test-Path -LiteralPath (Join-Path $PSScriptRoot 'config.json')) { $PSScriptRoot } else { Join-Path ([Environment]::GetFolderPath('UserProfile')) '.jobjakt-backlog/single-user-local' } } $root = [IO.Path]::GetFullPath($ControlRoot) if ($Command -in @('init','setup')) { $engine = Join-Path $PSScriptRoot '../automation/controller.py' if (-not (Test-Path -LiteralPath $engine)) { $engine = Join-Path $root 'controller.py' } if (-not $Repository) { if (Test-Path -LiteralPath (Join-Path $root 'config.json')) { $Repository = (Get-Content -LiteralPath (Join-Path $root 'config.json') -Raw | ConvertFrom-Json).repository } else { $Repository = & git -C $PSScriptRoot rev-parse --show-toplevel if ($LASTEXITCODE -ne 0) { throw 'Specify the isolated worker repository with -Repository' } } } } else { $engine = Join-Path $root 'controller.py' } if (-not (Test-Path -LiteralPath $engine -PathType Leaf)) { throw "Controller missing: $engine" } $arguments = @($engine, $Command, '--control-root', $root) if ($Command -notin @('init','setup') -and (Test-Path -LiteralPath (Join-Path $root 'config.json'))) { $config = Get-Content -LiteralPath (Join-Path $root 'config.json') -Raw | ConvertFrom-Json if ($Python -eq 'python' -and $config.pythonExecutable) { $Python = $config.pythonExecutable } } if ($Repository) { $arguments += @('--repository', $Repository) } if ($Stage) { $arguments += @('--stage', $Stage) } if ($Manifest) { $arguments += @('--manifest', $Manifest) } & $Python @arguments exit $LASTEXITCODE