podman-client-dotnet/utils/modules/ScriptConfig.psm1
2026-08-14 21:02:41 +02:00

36 lines
894 B
PowerShell

#requires -Version 7.0
#requires -PSEdition Core
function Get-ScriptSettings {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$ScriptDir,
[Parameter(Mandatory = $false)]
[string]$SettingsFileName = 'scriptSettings.json'
)
$settingsPath = Join-Path $ScriptDir $SettingsFileName
if (-not (Test-Path -LiteralPath $settingsPath -PathType Leaf)) {
throw "Settings file not found: $settingsPath"
}
return Get-Content -LiteralPath $settingsPath -Raw | ConvertFrom-Json
}
function Assert-Command {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Command
)
if (-not (Get-Command $Command -ErrorAction SilentlyContinue)) {
throw "Required command '$Command' is missing. Aborting."
}
}
Export-ModuleMember -Function Get-ScriptSettings, Assert-Command