param(
  [Parameter(Mandatory = $true)] [string] $Program,
  [Parameter(Mandatory = $true)] [string] $Mode,
  [Parameter(Mandatory = $true)] [string] $Source,
  [string] $FirstFrame,
  [string] $EndFrame,
  [string] $Output,
  [Parameter(Mandatory = $true)] [string] $Report
)

$programArguments = if ($Mode -eq '--automation-plan') {
  @($Mode, $Source, $FirstFrame, $EndFrame, $Report)
} elseif ($Mode -eq '--automation-export') {
  @($Mode, $Source, $Output, $Report)
} else {
  @($Mode, $Source, $Report)
}

$process = Start-Process -FilePath $Program -ArgumentList $programArguments -Wait -PassThru -WindowStyle Hidden
exit $process.ExitCode
